Kivy Reef: A touchscreen interface for reef-pi - Announcements and Discussion thread

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
Kivy Reef: A touchscreen interface for reef-pi

This thread is for announcements and discussion of Kivy Reef, a touchscreen interface client for reef-pi, written in Kivy and Python.

All code and installation instructions are located on GitHub: https://github.com/natbird/kivy-reef

Kivy Reef's current features include:
  • Display sensor readings (temperature, pH, flowmeters)
  • Control equipment (On/Off)
  • View usage of dosers and ATOs
  • Run/reverse macros
  • View system information and re-load reef-pi / reboot / shutdown host
Screenshots:
1634245540143.png
1634245561836.png
1634245573957.png
1634245590525.png
1634245613144.png
1634245620326.png
 
Reef Chasers Aquaculture
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
Looks awesome. Thank you for sharing. I’ll install and let you know how it goes
Thanks Ranjib! I should say that I am not an experienced programmer, so there are likely to be bugs and other things requiring improvement.
 

Ranjib

7500 Club Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 16, 2016
Messages
9,191
Reaction score
15,875
Review score
+0 /0 /-0
Location
Pleasant Hill, Concord
Thanks Ranjib! I should say that I am not an experienced programmer, so there are likely to be bugs and other things requiring improvement.
bugs in software is like algae in reef tanks :). they'll come and go. its part of the process. you made an attempt, shared it with us, we get to learn new things and take this an opportunity to collaborate further for a common good, and that excites me.
 

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
Hi, as I told you in your build thread this is an amazing work :D
I'm trying Kivy-Reef, when I try to start it with "python3 main.py" inside kivy-reef folder, I have this error:

File "/home/pi/kivy-reef/screens.py", line 74, in __init__
self.temp_entities.changedBind(self.recreateWidgets) # Bind the changed property to the recreateWidgets function
AttributeError: 'NoneType' object has no attribute 'changedBind'

what can it be?
I've run the test code for kivy and it seems to work just fine.
Thank you again for your work!
 
Fritz
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
Hi, as I told you in your build thread this is an amazing work :D
I'm trying Kivy-Reef, when I try to start it with "python3 main.py" inside kivy-reef folder, I have this error:

File "/home/pi/kivy-reef/screens.py", line 74, in __init__
self.temp_entities.changedBind(self.recreateWidgets) # Bind the changed property to the recreateWidgets function
AttributeError: 'NoneType' object has no attribute 'changedBind'

what can it be?
I've run the test code for kivy and it seems to work just fine.
Thank you again for your work!
Hi Simon, Thanks for your kind words!

That is definitely a bug in my code. I have committed an update on GitHub which should hopefully fix this issue. If you run 'git pull' in the directory where you cloned kivy-reef, it should fetch the updated code. Note, since the initial release I have added some rudimentary support for controlling lights via MQTT (I need to document how to configure this), which requires the paho-mqtt Python library to be installed if you do not already have this (pip3 install paho-mqtt).

It is great to have other people running my code and identifying bugs so that I can improve kivy-reef!
 

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
Hi, thank you for your quck reply! :D with the update now it works!
Now I have another question, how do I setup the ip of the rpi where I'm running Reef-Pi?

P.S. if I press on the touchscreen on my ssh terminal I have this message:

INFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org /> EVDEV KeyCode 330
 
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
Hi, thank you for your quck reply! :D with the update now it works!
Now I have another question, how do I setup the ip of the rpi where I'm running Reef-Pi?

That's great! If you mean set the IP in kivy-reef, this is done via the reefpi.ini config file which was created in the kivy-reef directory. Under the [server] section, update the 'host' entry to point to the IP of the pi running reef-pi: e.g. host = 192.168.1.100

P.S. if I press on the touchscreen on my ssh terminal I have this message:

INFO: The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org /> EVDEV KeyCode 330
What kind of touchscreen are you using and are you running kivy-reef on a desktop environment or from the console? Is the touchscreen supported by the Linux kernel? Try 'dmesg | grep touch' to see if the touchscreen is detected.

You may need to configure it in your kivy config file (should be /home/pi/.kivy/config.ini): see https://kivy.org/doc/stable/api-kivy.input.providers.hidinput.html and https://kivy.org/doc/stable/api-kivy.input.providers.mtdev.html

I found that I had to add 'mtdev_%(name)s = probesysfs,provider=mtdev' to the [input] section of my kivy.ini config file to get my touchscreen (a WaveShare 5") working.
 

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
Thank you again!
The Ip address now works, I can reach the reef-pi controller.

I'm using a 7.0 inch display:

dmesg | grep touch tell me this:

[ 7.553278] hid-multitouch 0003:1A86:E2E3.0001: input,hiddev96,hidraw0: USB H ID v1.00 Device [wch.cn USB2IIC_CTP_CONTROL] on usb-3f980000.usb-1.3/input0


I'm using Raspberry Pi os with desktop environment, I'll check the document you've linked ;)

I'm also unable to find my kivy.ini config file. do you have a path to the file?
 
Last edited:
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
Thank you again!
The Ip address now works, I can reach the reef-pi controller.

I'm using a 7.0 inch display:

dmesg | grep touch tell me this:

[ 7.553278] hid-multitouch 0003:1A86:E2E3.0001: input,hiddev96,hidraw0: USB H ID v1.00 Device [wch.cn USB2IIC_CTP_CONTROL] on usb-3f980000.usb-1.3/input0
That looks like it is recognised and should be supported :)

I'm using Raspberry Pi os with desktop environment, I'll check the document you've linked ;)

I'm also unable to find my kivy.ini config file. do you have a path to the file?
My mistake, the file is config.ini rather than kivy.ini (so /home/pi/.kivy/config.ini): https://kivy.org/doc/stable/guide/config.html

The suggestion here (https://kivy.org/doc/stable/api-kiv...s.html#module-kivy.input.providers.probesysfs) is to add the following lines to the [input] section, which should make most touchscreens work on linux:
# using mtdev
device_%(name)s = probesysfs,provider=mtdev
# using hidinput
device_%(name)s = probesysfs,provider=hidinput

Also, make sure that your sdl2 is up to date if you haven't done an 'apt upgrade' recently. The message you have may be due to using an older version of sdl: https://stackoverflow.com/questions/61227587/kivy-on-release-not-working-on-touchscreen-sdl-issue
 
BRS

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
Hi,
I've added the same code line that you've used and it work perfectly! :D The user interface is very very nice!

Now there's a quick way to autostart Kivy-Reef on boot? an maybe to add a desktop icon to launch it manually in case of a crash?
Thank you again for your patience :)
 
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
My test version, it's working very well! :) Thanks again @NXE I only have to setup the auto start and the desktop icon :)
That's fantastic. It's great to see Kivy Reef running on hardware which is not my own!

As you are running on a desktop environment, it should be straightforward to autostart Kivy Reef on login by creating a .desktop shortcut and placing it in the autostart folder. There are some instructions on how to do this here: https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/method-2-autostart

For your setup, setting the Exec line as follows should to the trick:
Exec=/usr/bin/python3 /home/pi/kivy-reef/main.py

You should be able to copy the .desktop file you create to your desktop to use as a manual shortcut as well.
 

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
That's fantastic. It's great to see Kivy Reef running on hardware which is not my own!

As you are running on a desktop environment, it should be straightforward to autostart Kivy Reef on login by creating a .desktop shortcut and placing it in the autostart folder. There are some instructions on how to do this here: https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup/method-2-autostart

For your setup, setting the Exec line as follows should to the trick:
Exec=/usr/bin/python3 /home/pi/kivy-reef/main.py

You should be able to copy the .desktop file you create to your desktop to use as a manual shortcut as well.
Thank you again! it starts after boot but not in full screen. It starts has a windows...
 
Avast
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
it was that simple.. it works :D Now I have to test all the functions! Thank you very very much!
Do you have a max items numer for each page? for example if I have 10 different sensors I can see all of them in the sensor page?
It will be very nice if there will be some sort of screen saver mode.. for example if no touch is detected for n second it will turn black the display or control a GPIO pin to turno ON/OFF lcd backlight
 
OP
NXE

NXE

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Apr 8, 2020
Messages
38
Reaction score
94
Review score
+0 /0 /-0
Location
London
it was that simple.. it works :D Now I have to test all the functions! Thank you very very much!
Great :D
Do you have a max items numer for each page? for example if I have 10 different sensors I can see all of them in the sensor page?
There is no limit, but currently the text does not automatically scale to the available space, so text may be cutoff/overlap past a certain number of sensors. That is something I want to improve in the future as well as add support for landscape orientation.
It will be very nice if there will be some sort of screen saver mode.. for example if no touch is detected for n second it will turn black the display or control a GPIO pin to turno ON/OFF lcd backlight
If you are running under a desktop environment, the OS should handle putting the display into power save mode. Make sure that allow_screensaver is set to 1 in your .kivy/config.ini. I do want to add a way of blanking the screen to prevent burn in where Kivy Reef is run directly from the console.
 

Simonv92

Community Member
Review score
+0 /0 /-0
View Badges
Joined
Oct 21, 2014
Messages
55
Reaction score
46
Review score
+0 /0 /-0
Location
Italy
If you are running under a desktop environment, the OS should handle putting the display into power save mode. Make sure that allow_screensaver is set to 1 in your .kivy/config.ini. I do want to add a way of blanking the screen to prevent burn in where Kivy Reef is run directly from the console.
Thank you again! I already have allow_screensaver set to 1. If I close Kivy Reef my display after some time turns black..
I've found this youtube video that shows how to turn on or off the display:

maybe I can use these command in a script..
 
AquaCave Logo Banner

Have you ever torn down a tank over an issue you couldn't seem to beat?

  • Yes! I have. (Tell us about what issue you faced in the thread.)

    Votes: 176 24.2%
  • No. Thankfully, I haven't.

    Votes: 376 51.7%
  • Nope, but it almost happened. (Share your experience in the thread.)

    Votes: 53 7.3%
  • Not yet, but I'm almost there. (Tell us what you're dealing with.)

    Votes: 61 8.4%
  • If you reef long enough, this will eventually happen to you.

    Votes: 47 6.5%
  • Other

    Votes: 14 1.9%
Torch SALE
Top