Skip to content

Instantly share code, notes, and snippets.

@oskar456
Created November 22, 2016 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oskar456/bf450e02dd47e2223414c733f01101b5 to your computer and use it in GitHub Desktop.
Save oskar456/bf450e02dd47e2223414c733f01101b5 to your computer and use it in GitHub Desktop.
LED blink clock – flash LED every second
#!/bin/sh /etc/rc.common
# Copyright (C) 2016 OpenWrt.org
START=99
USE_PROCD=1
start_service()
{
procd_open_instance
procd_set_param command "/root/blinkclock.py"
procd_close_instance
}
#!/usr/bin/env python2.7
import time
import os
ledpath="/sys/class/leds/omnia-led:power/"
autonomous = os.path.join(ledpath, 'autonomous')
if os.path.exists(autonomous):
with open(autonomous, 'w') as aut:
aut.write('0')
with open(os.path.join(ledpath, 'trigger'), "w") as trg:
trg.write('oneshot')
while True:
now = time.time()
time.sleep(1 - now%1)
with open(os.path.join(ledpath, 'shot'), "wb") as shot:
shot.write('1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment