Code for using CFA-835 to display system information in Linux

irix

New member
I'm sure someone can take this code (based on Crystal Fontz Linux demo code) and make it more functional. I'm not a developer and this is my first crack as writing something this complicated. Tested and in use with my CFA-835 under Mac OS X 10.10.2 and Debian 7 3.2.65.

To use: Unzip, run "make" to build, and then check out "test_all_func.sh" to see how to use it. You'll need a microSD card with the included fonts copied on to it installed in your LCD for -everything- to work. The font names are hard-coded (more ugliness) because I couldn't figure out a better way to do it. The image below is from "lcd_update.sh" on my Debian fileserver. This script is run by cron every minute.



Implemented (some of these are from the original example code of course):
Control of the 4 LEDs: off, red, green, amber
Clear the LCD screen
Send lines of text to the LCD screen using the default built-in font. (4lx20c?)
Send lines of text to the screen using the custom fonts.
Control the backlight: off, low, med, high, max, default (between low and off)
Control the keypad backlight: off, low, med, high, max, default (between low and off)
For "Chicago" there's 3 columns defined that can be updated since it's not a fixed-width font.

As a side note, I'm not sure if it's bad to constantly be loading fonts in slot# or not. This program does it every time one of the custom fonts is used.

http://irix7.com/cfa835/sfpdispctl.zip
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Mark

Administrator
Very nice work :)
I think i'll install a CFA835 in my Debian Linux server just so i can give this a try.

As a side note, I'm not sure if it's bad to constantly be loading fonts in slot# or not. This program does it every time one of the custom fonts is used.
There is nothing wrong with that at all.
 

ohmantics

New member
It's a pleasure to see Chicago and Monaco used here. Monaco hasn't been the same since they made the TrueType version.
 

shotsy242

New member
Is there any chance that you can provide the sample bash code to draw a cpu bar or disk full bar, or load an image for the example above, Just trying to wrap my head around using this also, how is it that there are more than 4 lines of text displayed at once. I'm assuming that the font size has something to do with that buy I dont see it defined in the bash code.

Thanks in advance, sorry about the lame questions. Here's something I'm working on with LCDproc on another LCD display that limits me to 20x2 but I'm looking forward to using this new beast!

#!/bin/bash
FIFO=/tmp/LCD
sleep 5

mkfifo $FIFO
nc localhost 13666 <> /tmp/LCD 1>/dev/null 2>/dev/null &
trap "kill $!; rm -f $FIFO; exit;" EXIT HUP INT TERM ABRT


cat <<EOF > $FIFO
hello
client_set name test
screen_add screen0
screen_set screen0 -duration 40
widget_add screen0 line1 string
widget_add screen0 line2 string
screen_add screen1
screen_set screen1 -duration 40
widget_add screen1 line1 string
widget_add screen1 line2 string
screen_add screen2
screen_set screen2 -duration 100
widget_add screen2 line1 string
widget_add screen2 line2 string
EOF

while [[ true ]]; do

CPUstat=$(cat /proc/stat | grep 'cpu ' | awk '{printf "%.1f%",(($2+$4)*100/($2+$4+$5))}')
CPUtemp=$(sensors -f | grep SYSTIN | awk '{print $2}' | tr -d '°')
CPUmodel=$(cat /proc/cpuinfo | grep -m1 "model name" | awk '{print $6,$8,$9}')
MEMinfo=$(free -m | awk 'NR==2{printf "%s/%s %.2f%%\n", $3,$2,$3*100/$2 }')
DATE=$(date "+%A %b %d %Y")
TIME=$(date +%T)

cat <<EOF > $FIFO
widget_set screen0 line1 1 1 "Tmp:$CPUtemp Use:$CPUstat"
widget_set screen0 line2 1 2 "Mem:$MEMinfo"
widget_set screen1 line1 1 1 "Name: `hostname -f`"
widget_set screen1 line2 1 2 " IP: `hostname -I`"
widget_set screen2 line1 1 1 " $DATE"
widget_set screen2 line2 1 2 " $TIME"
EOF

sleep 1
done
 

shotsy242

New member
Kens CFA-835 project

Is there any chance that you can provide the sample bash code to draw a cpu bar or disk full bar, or load an image for the example above, Just trying to wrap my head around using this also, how is it that there are more than 4 lines of text displayed at once. I'm assuming that the font size has something to do with that buy I dont see it defined in the bash code.

Thanks in advance, sorry about the lame questions. Here's something I'm working on with LCDproc on another LCD display that limits me to 20x2 but I'm looking forward to using this new beast!

#!/bin/bash
FIFO=/tmp/LCD
sleep 5

mkfifo $FIFO
nc localhost 13666 <> /tmp/LCD 1>/dev/null 2>/dev/null &
trap "kill $!; rm -f $FIFO; exit;" EXIT HUP INT TERM ABRT


cat <<EOF > $FIFO
hello
client_set name test
screen_add screen0
screen_set screen0 -duration 40
widget_add screen0 line1 string
widget_add screen0 line2 string
screen_add screen1
screen_set screen1 -duration 40
widget_add screen1 line1 string
widget_add screen1 line2 string
screen_add screen2
screen_set screen2 -duration 100
widget_add screen2 line1 string
widget_add screen2 line2 string
EOF

while [[ true ]]; do

CPUstat=$(cat /proc/stat | grep 'cpu ' | awk '{printf "%.1f%",(($2+$4)*100/($2+$4+$5))}')
CPUtemp=$(sensors -f | grep SYSTIN | awk '{print $2}' | tr -d '°')
CPUmodel=$(cat /proc/cpuinfo | grep -m1 "model name" | awk '{print $6,$8,$9}')
MEMinfo=$(free -m | awk 'NR==2{printf "%s/%s %.2f%%\n", $3,$2,$3*100/$2 }')
DATE=$(date "+%A %b %d %Y")
TIME=$(date +%T)

cat <<EOF > $FIFO
widget_set screen0 line1 1 1 "Tmp:$CPUtemp Use:$CPUstat"
widget_set screen0 line2 1 2 "Mem:$MEMinfo"
widget_set screen1 line1 1 1 "Name: `hostname -f`"
widget_set screen1 line2 1 2 " IP: `hostname -I`"
widget_set screen2 line1 1 1 " $DATE"
widget_set screen2 line2 1 2 " $TIME"
EOF

sleep 1
done
Here's what I've done with my new CFA-835 https://www.youtube.com/watch?v=oJDAFlvO0_Y&feature=youtu.be
 

Attachments

USB LCD Displays - Graphic and Character LCDs with a Keypad
Top