Sleep timer with automatic volume control - android-studio

My project is music player in Android app development I want to add a sleep timer with automatic volume reduce please help me

Related

A more efficient way of streaming video on the pi

I am a surfer/kitesurfer and i live in the UAE. I'm trying to build a basic weather station that can provide wind and webcam details for a spot that is in a remote location. I am using a pi4 1GB and i am almost ready to install the station on site. My skills are fairly basic but this is where i am at:
pi4 runs ddns so it's dynamic address is accessible remotely with port forwarding - done
weewx uploads wind and weather info from the sensor to windguru - this is on track and will be done by the end of the week when a final part arrives
motion eye provides the video stream of camera 1 and camera 2 - done and visible from outside the LAN
Run apache/mysql/wordpress to provide a basic interface for people to check the info from their browser - almost done.
Now, regarding point 3... i am noticing that this is crippling the pi. Running nmon i can see each camera is utilising 110% of the CPU per camera. That is with minimal video streaming settings and a 1 fps rate. With both cameras running the pi is almost inaccessible through vnc or ssh and it gets very hot - i need to keep restarting it as it freezes.
I don't need a live stream, i'd be happy with an image every 30 seconds. Even if i disable video streaming and use the still image capture, 'motion' is still costing the CPU 110% per camera just to monitor it. Is there a better piece of software that i can be using?
I tried to edit sudo nano /etc/motion/motion.conf hoping to reduce the fps that motion uses to initialize the device but it doesn't affect the CPU usage.
Important to note, my camera is connected via IP and motion is connected to the device via RTSP://
Would appreciate any suggestions.
Thanks,
Sean.
Try UV4L and RPi_Web_Cam_Interface as alternatives to Motion.
RPIWCI is nicely documented at this site
https://elinux.org/RPi-Cam-Web-Interface
The preview mjpeg stream from RPIWCI can be found at the URL http://YourPiIP:Port/cam_pic_new.php
You can set the quality and size using the 'camera control' bar at the bottom of the preview/control page found at yourPiIP:80/html/ (change the port to your forwarding port)
There is also the opportunity to use a timelapse function that might provide a different route to get a 1fps jpeg stream, I have not tried this.
I am currently streaming the preview at 1024x720 ~15fps compression quality 30% to several devices on my local network and the Pi4 is utilising only about 10% CPU.
Other comments.....
Have you tried setting the GPU memory split on the Pi to 1024
Also have you tried the command 'top' at the linux prompt to see what processes are using all the CPU, raspimjpeg uses between 2 and 3 % on my Pi4.
Hope this helps, Heath.

Task schedule management

I am doing a pet feeder with React-Native app - Node.js server - Arduino (ESP32) but I can't figure it out how to make it work so it drops food at specific times.
I was looking into nodeJS libraries like node-schedule or cron but I can't figure it out or they don't seem to fit my needs.
At this moment I can make it drop food when I press a button in my app, but that would make it too simple (I want both manual AND automatized tasks).
My intention is to schedule feeding hours for your pet to eat, for example at 9:00, at 15:00 and at 21:00 via app, with some sort of alarms, while also being able to check them on demand and edit/delete options.
Any ideas on how could I do it, please?
You don't necessarily have to trigger the "drop food" command from the node app. I've written firmware for a device that connects to wifi, updates its internal date/time from a NTP server, then wakes up at a specified time every data to connect to a server and get setting updates. Ours is a battery powered device, so it doesn't just stay connected to the server all the time, and I used the ESP-IDF but the code was simple enough. I did some research and you can do the same process with an ESP32 using the Arduino Core.
Basic Idea
You could:
Set the times you want the feeding to occur in the app, which then sends those times to the device through BLE or your node app and store them in Flash
Calculate the number of milliseconds until the next feeding
Set a FreeRTOS timer to interrupt after that number of milliseconds to trigger a feeding event
Then after a feeding event occurs:
Check Flash for the next feeding event
Calculate the number of milliseconds
Set a FreeRTOS timer to interrupt and trigger a feeding event
Repeat
Resources:
Setting Local Time on Arduino using NTP
Using FreeRTOS timer interrupts on Arduino

Tizen app : gear current consumption is too high on sleep mode

I have an application in Tizen in which I am recording the sensor data of some activity of a user. The application is hybrid type and the accelerometer, gyroscope data is registered in the native service application.
I have an option where the user can pause the recording of data. When the device goes to is paused, sensor_listener_unset_event_cb(listener_accelero) and device_power_release_lock(POWER_LOCK_CPU) are called. Hence, it is expected that no sensor data will be received while in sleep state.
However, on submitting to Tizen store I get the following rejection message :
[CURRENT] Gear current consumption is too high on sleep mode
- Tested application
Min current: 23.1 mA, Average current: 24.173 mA
- Samsung Gear standard current consumption
Min current: 4 mA, Average current: 7 mA
The video attachment shows that reported current consumption is in sleep state after pausing the recording. What could be the reason for such high current drawn? Also, how can I verify whether some tweak actually solves the problem. Is there any application which does the current/power profiling for Samsung gear S2/S3?
Keeping app awake in device screen off state is sensitive issue. Have you tried using SENSOR_OPTION_ALWAYS_ON
sensor_listener_set_option(listener, SENSOR_OPTION_ALWAYS_ON);
Sensor API: Sensor option
You may also see this links:
Allowing Applications to Run on the Background
Tizen accelerometer sensor usage
Stop the sensor listeners when the app is going to pause state. Then again start the listeners when app is up front again if necessary.
sensor_listener_stop ( listener )

How to pause or stop currently playing audio that is not from my app, from background?

I want to pause and/or stop background audio that is currently playing on the phone (this audio being from other apps). And I want to do this from a background task, when my app is not running/visible.
There are about 1000 apps in the store that can be used to stop the currently playing audio - but these apps need to stay open all the time. And they tend to be buggy on Windows 10.
So there are actually two questions:
How do these other apps stop the audio (that is not their own) pre Windows 10 Mobile (e.g. on Windows Phone 8/8.1)?
How can I pause and/or stop audio (that is currently playing and not my own) in Windows 10 Mobile latest (>= Anniversary update)?
There have been extensions of the background process and audio model in Windows 10 so I'm hoping for new possibilities here.

SW2 Control Extension stop updating the Display when the smartphone is idle

I'm working on a Control Extension for Sony SmartWatch 2 that needs to update a TextView every second on the SW2 Display.
It happens that if I've my Smartphone connected via USB or when USB disconnected if I've my Smartphone screen active, the Control Extension works as expected on SmartWatch 2.
But soon my SmartPhone screen idles, the control extension stops the regular TextView updates. First starts breaking and eventually get stuck. The Extension is not closed by the Host Application and the SW2 continues well paired with the Smartphone. In fact if I touch the display, the Extension appears to recover state for some moments with a few TextView updates, but rapidly breaks and get stuck again.
Meanwhile, if I turn ON my Smartphone screen, the control extension recovers the state and resume the normal TextView updates.
It seems that when the smartphone idles it stops to send the regular bluetooth messages to the SW2. I've tried many solutions to avoid this behaviour, even set the keepRunningWhenConnected to true. But the behaviour is allways the same.
Is anyone also having this problem or have a clue for the solution?
Thanks :)
What model of phone are you using?
If it is indeed that the bluetooth connection is not persisting then you could try the following possible solutions:
Is there a setting on the phone to keep bluetooth on even when going into idle?
You could set the phone to not go into idle while your app is running, of course this is not ideal as it will cause battery drain.
Ok. After testing and testing several solutions (AlarmManager, BluetoothAdapter, etc...) I came to following conclusion:
Its not the Bluetooth connection that is lost, otherwise the SmartWatch 2 would lost connection with the Smartphone, and that never happens. In fact is the Phone CPU that is lost by the ControlExtension, because when the Smartphone idles the CPU also idles. By loosing the Phone CPU the ControlExtension cannot process the "sendText(...)" call and this means that the corresponding upper call "sendHostApp(...)" that uses the Bluetooth messages its also never called, that's why the TextView is not updated on the SmartWatch 2.
Also I think that when I touch the SmartWatch 2 screen, this triggers an hardware interruption that wake up the Phone CPU for short seconds to answer to the SmartWatch 2 Touch Event and thats why when I touch the SW2 screen the TextView is updated a few times before get stuck again.
This works fine for static Control Extension applications that only display static content and/or replies to the user (touch, swipe, etc...) events. But its a complete disaster for Control Extensions applications that need to be doing some processing regardless the user direct interaction.
I never though in this terms because I though that it was the job of the SmartConnect Host Application to guarantee Phone CPU to the Control Extensions.
So the solution for some apps could be using an AlartManager in order to schedule wake up calls to do some processing. For other apps the solution could be the PowerManger and use a wakelock.aquire()/wakelock.release().

Resources