LCD4linux

I've written a plugin for lcd4linux so I can use the buttons on my usb-lcd to activate wireless lan (atheros madwifi driver in my soekris box) for just the time I need it.

This works as follows: If I press the wireless-button once, I get 15 minutes of wireless. If I press it again, the current time is doubled, so I'd have 30 minutes of wireless. And so on, and so on...

The clue is that the exec-plugin of lcd4linux always repeats the commands once it's fired. My plugin only forks and exec's the command once it is called. So you can have button triggers.

What you need:

  • my patch for lcd4linux unless it's already included in lcd4linux (I've sent it to the devel-team).
  • an LCD with buttons that is supported by lcd4linux - I'm using a Crystalfontz 631
  • A wireless Access-Point that you can fire up with some command - let's say iwconfig ath0 txpower auto and hostapd for example.
  • my lcd4linux.conf below or for download here

Note: My lcd4linux-config here requires you to write shell-scripts to bring your wireless up and down. Those shell-scirpts HAVE to start with a shebang (e.g. #!/bin/bash or #!/bin/perl) otherwhise it won't execute. Furthermore my plugin suffers from one bug: The last argument can't be a '0'. So you can't execute expression button_exec('/usr/local/bin/some-script','argument1','argument2','0') - Got me?

Oh, one last thing - Aside from some animated Icons in my config I also like to activate online-radio by pressing one button (left upper button). So the radio-variable has nothing to do with the radio of the wireless, it's listening to online radio.

lcd4linux.conf:

# config by wogri - www.wogri.com

Display Curses {
Driver 'Curses'
Size '20x2'
}

Display CF631 {
Driver 'Crystalfontz'
Model '631'
Port '/dev/ttyUSB0'
Speed 115200
Contrast 90
Backlight backlight
Icons 5
}

Variables {
backlight 100
counter 1
radio 0
wlan 10
wlan_time 30
wlan_activated 0
result 0
dummy 1
radio 0
}

Widget CPU {
class 'Text'
expression loadavg(1)
prefix 'Load: '
width 9
align 'L'
update 500
speed 500
}

Widget Mail {
class 'Text'
expression exec('/usr/local/sbin/mailstatus',30000)
width 2
align 'L'
update 10000
}

Widget Wlan_status {
class 'Text'
width 10
align 'L'
update 1000
expression wlan = wlan == -1 ? -1 : wlan - 1 ; hours=wlan/3600 ; \
hours = floor(hours) ; minutes = (wlan - hours * 3600)/60 ; \
minutes = floor(minutes) ; \
wlan < 0 ? 'WLAN: off' : hours . 'h ' . minutes . 'min'
}

Widget Wlan_countdown {
class 'Timer'
expression button_exec('/usr/local/sbin/wlan_off') ; wlan = -1
active !wlan
update 500
}

Widget start_radio {
class 'Timer'
expression button_exec('/usr/local/bin/start_radio') ; radio = 2
active radio==1
update 1000
}

Widget stop_radio {
class 'Timer'
expression button_exec('/usr/local/bin/stop_radio') ; radio = 0
active radio==3
update 1000
}

Widget N {
class 'Text'
expression 'n'
length 1
}

Widget C {
class 'Text'
expression 'c'
length 1
}

Widget Eth0Bar {
class 'Bar'
expression netdev('eth0', 'Rx_bytes', 500)
expression2 netdev('eth0', 'Tx_bytes', 500)
length 4
direction 'E'
update 200
}

Widget CPUBar {
class 'Bar'
expression proc_stat::cpu('busy', 500)
expression2 proc_stat::cpu('system', 500)
length 4
direction 'E'
update 200
}

Widget key_left_up {
class 'Keypad'
position 'up'
expression radio = radio + 1
}

Widget key_right_up {
class 'Keypad'
position 'right'
expression LCD::backlight(100)
}

Widget key_left_down {
class 'Keypad'
position 'left'
expression button_exec('/usr/local/sbin/wlan_on') ; \
wlan = wlan == -1 ? 3600*12 : 3
}

Widget key_right_down {
class 'Keypad'
position 'down'
expression button_exec('/usr/local/sbin/wlan_on') ; \
wlan = wlan == -1 ? 15*60+1 : wlan*2
}

Widget Time {
class 'Text'
expression strftime('%H:%M:%S',time())
width 9
align 'L'
update 1000
speed 500
}

Widget Wireless_on {
class 'Icon'
speed 200
visible wlan != -1
Bitmap {
Row1 '......|......|*.....|.*....|..*...|...*..|....*.|'
Row2 '*.....|.*....|..*...|...*..|....*.|......|......|'
Row3 '.*....|..*...|...*..|....*.|......|......|*.....|'
Row4 '..*...|...*..|....*.|......|......|*.....|.*....|'
Row5 '..*...|...*..|....*.|......|......|*.....|.*....|'
Row6 '.*....|..*...|...*..|....*.|......|......|*.....|'
Row7 '*.....|.*....|..*...|...*..|....*.|......|......|'
Row8 '......|......|*.....|.*....|..*...|...*..|....*.|'
}
}

Widget Wireless_off {
class 'Icon'
speed 300
visible wlan == -1
Bitmap {
Row1 '......|......|......|......|......|'
Row2 '......|......|......|......|......|'
Row3 '**.**.|**.**.|**.**.|**.**.|**.**.|'
Row4 '**.**.|**.**.|**.**.|**.**.|**.**.|'
Row5 '......|......|......|......|......|'
Row6 '**.**.|**....|**.**.|...**.|**.**.|'
Row7 '**.**.|**....|**.**.|...**.|**.**.|'
Row8 '......|......|......|......|......|'
}
}

Widget Mail1 {
class 'Icon'
speed 8000
Bitmap {
Row1 '......|'
Row2 '******|'
Row3 '**....|'
Row4 '*.*...|'
Row5 '*..*..|'
Row6 '*...*.|'
Row7 '*....*|'
Row8 '******|'
}
}


Widget Mail2 {
class 'Icon'
speed 8000
Bitmap {
Row1 '......|'
Row2 '*****.|'
Row3 '...**.|'
Row4 '..*.*.|'
Row5 '.*..*.|'
Row6 '*...*.|'
Row7 '....*.|'
Row8 '*****.|'
}
}


Widget Radio {
class 'Icon'
speed 800
visible radio==2
Bitmap {
Row1 '******|......|'
Row2 '****.*|....*.|'
Row3 '****.*|....*.|'
Row4 '****.*|....*.|'
Row5 '****.*|....*.|'
Row6 '**...*|..***.|'
Row7 '*....*|.****.|'
Row8 '**..**|..**..|'
}
}


Layout Default {
Row1.Col1 'Time'
Row1.Col10 'N'
Row1.Col11 'Eth0Bar'
Row1.Col15 'C'
Row1.Col16 'CPUBar'
Row2.Col1 'Mail'
Row2.Col3 'Mail1'
Row2.Col4 'Mail2'
Row2.Col6 'Radio'
Row2.Col9 'Wireless_off'
Row2.Col10 'Wireless_on'
Row2.Col11 'Wlan_status'
Keypad1 'key_left_up'
Keypad2 'key_right_up'
Keypad3 'key_left_down'
Keypad4 'key_right_down'
Timer1 'Wlan_countdown'
Timer2 'start_radio'
Timer3 'stop_radio'
}

Display 'CF631'
Layout 'Default'
Last Update: 26.01.2008