React Native: How to detect phone with dynamic island? - react-native

Is it possible to target phones (iPhone 14 Pro and iPhone 14 Pro Max) with dynamic islands with React Native?

Just to complement the other answer it is also possible to use react-native-device-info
const iPhonesWithDynamicIsland = ['iPhone15,2', 'iPhone15,3']; // iPhone 14 Pro, iPhone 14 Pro Max
const isIphoneWithDynamicIsland = iPhonesWithDynamicIsland.includes(DeviceInfo.getDeviceId());
console.log(isIphoneWithDynamicIsland);
or even simpler:
DeviceInfo.hasDynamicIsland()

You can simply detect an iPhone with a dynamic island by using react-native-safe-area-context by getting the height/top of it, if it was 59 then this iPhone has a dynamic island
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const insets = useSafeAreaInsets();
console.log(insets.top == 59 ? true : false ) // has dynamic
// this is some of the other heights of other iPhones
59 - iPhone 14 Pro / 14Pro Max
50 - iPhone 13 mini
47 - iPhone 12 / 12Pro / 13 / 13Pro / 13Pro Max / 14 / 14 Plus
44 - on iPhoneX
20 - on iOS device

Related

Media and Data Integrity Errors

I was wondering if anyone can tell me what these mean. From most people posting about them, there is no more than double digits. However, I have 1051556645921812989870080 Media and Data Integrity Errors on my SK hynix PC711 on my new HP dev one. Thanks!
Here's my entire smartctl output
`smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.0.7-arch1-1] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Number: SK hynix PC711 HFS001TDE9X073N
Serial Number: KDB3N511010503A37
Firmware Version: HPS0
PCI Vendor/Subsystem ID: 0x1c5c
IEEE OUI Identifier: 0xace42e
Total NVM Capacity: 1,024,209,543,168 [1.02 TB]
Unallocated NVM Capacity: 0
Controller ID: 1
NVMe Version: 1.3
Number of Namespaces: 1
Namespace 1 Size/Capacity: 1,024,209,543,168 [1.02 TB]
Namespace 1 Formatted LBA Size: 512
Namespace 1 IEEE EUI-64: ace42e 00254f98f1
Local Time is: Wed Nov 9 13:58:37 2022 EST
Firmware Updates (0x16): 3 Slots, no Reset required
Optional Admin Commands (0x001f): Security Format Frmw_DL NS_Mngmt Self_Test
Optional NVM Commands (0x005f): Comp Wr_Unc DS_Mngmt Wr_Zero Sav/Sel_Feat Timestmp
Log Page Attributes (0x1e): Cmd_Eff_Lg Ext_Get_Lg Telmtry_Lg Pers_Ev_Lg
Maximum Data Transfer Size: 64 Pages
Warning Comp. Temp. Threshold: 84 Celsius
Critical Comp. Temp. Threshold: 85 Celsius
Namespace 1 Features (0x02): NA_Fields
Supported Power States
St Op Max Active Idle RL RT WL WT Ent_Lat Ex_Lat
0 + 6.3000W - - 0 0 0 0 5 5
1 + 2.4000W - - 1 1 1 1 30 30
2 + 1.9000W - - 2 2 2 2 100 100
3 - 0.0500W - - 3 3 3 3 1000 1000
4 - 0.0040W - - 3 3 3 3 1000 9000
Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 + 512 0 0
1 - 4096 0 0
=== START OF SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
SMART/Health Information (NVMe Log 0x02)
Critical Warning: 0x00
Temperature: 34 Celsius
Available Spare: 100%
Available Spare Threshold: 5%
Percentage Used: 0%
Data Units Read: 13,162,025 [6.73 TB]
Data Units Written: 3,846,954 [1.96 TB]
Host Read Commands: 156,458,059
Host Write Commands: 128,658,566
Controller Busy Time: 116
Power Cycles: 273
Power On Hours: 126
Unsafe Shutdowns: 15
Media and Data Integrity Errors: 1051556645921812989870080
Error Information Log Entries: 0
Warning Comp. Temperature Time: 0
Critical Comp. Temperature Time: 0
Temperature Sensor 1: 34 Celsius
Temperature Sensor 2: 36 Celsius
Error Information (NVMe Log 0x01, 16 of 256 entries)
No Errors Logged`
Encountered a similar SMART reading from the same model.
I'm seeing a reported Media and Data Integrity Errors rate of a value that's over 2 ^ 84.
It could just be an error with its SMART implementation or the utility reading from it.
Converting your reported value of 1051556645921812989870080 to hex, we get 0xdead0000000000000000 big endian and 0x0000000000000000adde little endian.
Similarly, when I convert my value to hex, I get 0xffff0000000000000000 big endian and 0x0000000000000000ffff little endian, where f is just denotes a value other than 0.
I'm going to assume that the Media and Data Integrity Errors value has no actual meaning with regard to real errors. I doubt that both of us would have values that are padded with 16 0's when converted to hex. Something is sending/receiving/parsing bad data.
If you poke around the other reported SMART values in your post, and on my end, some of them don't seem to make much sense, either.

How to calculate distance using voltage from Q4X Analog Laser Sensor

I have a Q4X Stainless Steel Analog Laser Sensor to calculate the distance with analog output voltage.
It does display distance on Laser Sensor display and I am trying to do the same thing in my code using scale factor but its not matches with Laser Sensor display value.
here is my scaling factor.
#define A2D_SCL_LASER ( 11.81f / ( 10.0f - 0.0f ) ) // inches per volt
Devices specs:
Supply Voltage (Vcc)
12 to 30 V dc
Sensing Range—Threaded Barrel Models
500 mm models: 25 mm to 500 mm (0.98 in to 19.68 in)
300 mm models: 25 mm to 300 mm (0.98 in to 11.81 in)
100 mm models: 25 mm to 100 mm (0.98 in to 3.94 in)
Comparison of distance calculation in my code and sensor display
My values(mm) sensor display value(mm)
1V 29.9974 52
2V 59.944 80
3V 89.916 107
4V 119.888 134
5V 150.114 162
6V 179.832 190
7V 209.804 217
8V 240.03 245
9V 270.002 272
10V 300 300
Ref:
http://info.bannerengineering.com/cs/groups/public/documents/literature/185623.pdf
I simply fitted the sensor displayed value with the voltage you give in your question. The R²=1 means that the fit is perfect (or near perfect) and this is a good sign.
The equation you are searching for is
Distance(mm) = 27.533 x Volt + 24.467

Create a query that groups by multiple categories?

I have these:
colnames(w)
[1] "user_id" "install_date" "app_version" "user_session_id"
[5] "event_timestamp" "app_page" "time_seconds"
I want to get the mean time of each of session per app_page (3 overall) so i did this. Since there are 3 app versions i would like to plot all these 3 pages with the avg app time used on them per version.
This is what i did:
df=sqldf('select app_version,app,round(avg(time_seconds),0)
as time_app from w group by app_version')
df
which gives this:
app_version app_page time_app
1 v1 build 1019
2 v2 learn 910
3 v3 learn 966
but it doesn't look correct.
If i try this though
df1=sqldf('select app_version,app,round(avg(time_seconds),0) as time_app from w group by app')
df1
app_version app_page time_app
1 v2 build 1001
2 v2 draw 727
3 v2 learn 982
i think its correct but it has all the version included and not each one as a standalone.
Trying to plot it.
sw<-ggplot(data=df1, aes(x=app, y=time_app)) +
geom_bar(stat="identity") +facet_grid(app_version ~.)
sw
How to change the sql query so it gives the proper result and
thus the plot would provide each version with the avg time of every app page?
plot would provide each version with the avg time of every app page
This sounds like an aggregation along two dimensions:
select app, app_version, round(avg(time_seconds), 0) as time_app
from w
group by app, app_version
order by app, app_version;

Schedule local notification Xamarin Forms

I have a question about local notification in Xamarin.
I need to be able schedule more than one local notification in different hours.
What I mean ...
day 1
notification 1 - h 10 am - remember appointment 1
notification 2 - h 02 pm - remember appointment 2
notification 3 - h 08 pm - remember appointment 3
day 2
notification 1 - h 08 am - remember appointment 1
notification 2 - h 11 am - remember appointment 2
notification 3 - h 03 pm - remember appointment 3
I read this article but the implementation with SetInexactRepeating doesn't work in my case because the manager rememeber only one notification (example appointment 1) and not anything else.
Does Xamarin allow to create this scenario? And if yes, can anyone help me?
In order to have multiple alarms in Android, each one needs a unique identifier. In the article you linked to, zero is used each time. This could be your problem. See this answer for how to pass a unique identifier to the getBroadcast call (note passing _id instead of 0):
Intent intent = new Intent(load.this, AlarmReceiver.class);
final int _id = (int) System.currentTimeMillis();
PendingIntent appIntent = PendingIntent.getBroadcast(this, _id, intent,PendingIntent.FLAG_ONE_SHOT);

STM32f4 HID receive data

How to receive OUT report data from HOST PC in STM32f407 discovery board running as HID(USB) in device mode?
Is it possible?
I am thinking to send data from host using hidapi.
There is an official USB library. It is not easy, but you may try to run the examples and adapt them to your needs.
http://www.st.com/en/embedded-software/stsw-stm32046.html
Be careful with clock settings. I experienced problems with that. Here are the values I setup in system_stm32f4.c:
HSE = 8000000
PLL_M = 8
PLL_Q = 7
PLL_N = 336
PLL_P = 4
HSE is the crystal on the board. It replaces the embedded clock on the MCU. The other settings are slightly different from the values in the original configuration file. Here are the calculations of the different clocks:
PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
= 8000000 / 8 * 336 = 336000000
USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ
= 336000000 / 7
= 48000000
SYSCLK = PLL_VCO / PLL_P
= 336000000 / 4
= 84000000
HCLK = SYSCLK / 1
= 84000000
PCLK2 = HCLK / 1
= 84000000
PCLK1 = HCLK / 2
= 84000000 / 2
= 42000000
The “USB OTG FS” clock HAS to be >= 48MHz if you use USB FS. Otherwise the device won't be recognized.