Added files from github

This commit is contained in:
sinf committed 2026-10-11 11:56:36 +02:00
commit 2ec5d44c10
6 files changed
+997

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 Lasse Hassing
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
# P110Monitor
A simple CLI python app for monitoring TP-Link Tapo P110 power consumption using [TapoP100
](https://github.com/fishbigger/TapoP100) and [Rich](https://github.com/Textualize/rich)
## Screenshot
![](screenshot.png)
+14
View File
@@ -0,0 +1,14 @@
[auth]
email = email@email.email
password = p4sSw0rd
[Device 1]
ip = 192.168.1.2
[Device 2]
ip = 192.168.1.3
[Device with custom auth]
email = different@email.email
password = 4als0DifF3rent
ip = 192.168.1.4
+194
View File
@@ -0,0 +1,194 @@
import time, configparser
from PyP100 import PyP110
from rich.console import Console
from rich.live import Live
from rich.layout import Layout
from rich.panel import Panel
from rich.align import Align
def main():
devices = []
default_email = ""
default_password = ""
config = configparser.ConfigParser()
config.read('p110monitor.ini')
if 'auth' in config.sections() and 'email' in config['auth'].keys():
default_email = config['auth']['email']
if 'auth' in config.sections() and 'password' in config['auth'].keys():
default_password = config['auth']['password']
for s in [x for x in config.sections() if x != 'auth']:
name = s
ip = config[s]["ip"]
email = config[s]["email"] if "email" in config[s].keys() else default_email
password = config[s]["password"] if "password" in config[s].keys() else default_password
devices.append(P110Device(name, ip, email, password))
interface = CliInterface(devices)
interface.start()
class P110Device:
def __init__(self, name, ip, email, password):
self.name = name
self.ip = ip
self.email = email
self.password = password
self.connection = self.getConnection()
self.data = {}
self.history = []
self.last_read = 0
def getConnection(self):
try:
con = PyP110.P110(self.ip, self.email, self.password)
con.handshake()
con.login()
except:
con = None
return con
def update(self, force_new = False):
if force_new or self.connection is None:
self.connection = self.getConnection()
if self.connection is None:
self.data = {}
return
try:
self.data = self.connection.getEnergyUsage()
if "result" in self.data.keys():
self.last_read = time.mktime(time.strptime(
self.data["result"]["local_time"],
"%Y-%m-%d %H:%M:%S"))
self.history.append([self.last_read, self.data["result"]["current_power"]])
except:
if not force_new:
self.data = self.update(True)
if len(self.history) > 20000:
# Trim history in case app runs for long time.
# Will still result in always having at least 24 hours when
# updated every 5 seconds.
self.history = self.history[2000:]
return self.data
def validData(self):
return self.data is not None and ("result" in self.data.keys())
def currentPower(self):
return self.data["result"]["current_power"] / 1000.0
def average(self, minutes):
if self.last_read == 0:
return self.last_read
count = 0
value = 0
for h in reversed(self.history):
if self.last_read - h[0] > (minutes * 60):
break
count += 1
value += h[1]
return value / (count * 1000.0)
def last24(self):
return sum(self.data["result"]["past24h"]) / 1000.0
def weekday(self, day):
return sum(self.data["result"]["past7d"][day]) / 1000.0
def month(self):
return sum(self.data["result"]["past30d"]) / 1000.0
def year(self):
return sum(self.data["result"]["past1y"]) / 1000.0
class CliInterface:
def __init__(self, devices):
self.devices = devices
self.console = Console()
def generateLayout(self):
layout = Layout()
for d in self.devices:
layout.add_split(Layout(name=d.name))
row = layout[d.name]
row.split_row(
Layout(name="Now"),
Layout(name="24h"),
Layout(name="Month")
)
data = ""
if d.validData():
data += "Currently: %s W\n" % self.n2s(d.currentPower())
data += "1min avg: %s W\n" % self.n2s(d.average(1))
data += "5min avg: %s W" % self.n2s(d.average(5))
else:
data = "disconnected"
row["Now"].update(Align(
Panel(data, title="%s, Now" % d.name),
align="center",
vertical="middle"
))
data = ""
if d.validData():
data += "Last 24h: %s kWh\n" % self.n2s(d.last24())
data += "Today: %s kWh\n" % self.n2s(d.weekday(6))
data += "Yesterday: %s kWh" % self.n2s(d.weekday(5))
else:
data = "disconnected"
row["24h"].update(Align(
Panel(data, title="%s, Recent" % d.name),
align="center",
vertical="middle"
))
data = ""
if d.validData():
data += "Past 30 days: %s kWh\n" % self.n2s(d.month())
data += "Daily avg: %s kWh\n" % self.n2s(d.month()/30.0)
data += "Past year: %s kWh" % self.n2s(d.year())
else:
data = "disconnected"
row["Month"].update(Align(
Panel(data, title="%s, Long term" % d.name),
align="center",
vertical="middle"
))
return layout
def n2s(self, n):
if n >= 1000.0:
return " %.0f" % n
elif n >= 100.0:
return "%.1f" % n
elif n >= 10:
return "%.2f" % n
else:
return "%.3f" %n
def start(self):
for d in self.devices:
d.update()
with Live(self.generateLayout(), refresh_per_second=1, screen=True) as live:
while True:
for d in self.devices:
d.update()
live.update(self.generateLayout())
time.sleep(5)
if __name__ == "__main__":
main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+760
View File
@@ -0,0 +1,760 @@
/* Simple 3x3x3 LED cube animation code for PIC16.
* Originally tested with PIC16F690. Pinout in "format" section below under includes.
* Compiled with MPLAB XC.
*
* https://hassing.org/3x3x3-led-cube
*
* MIT License
*
* Copyright (c) 2022 Lasse Hassing
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// CONFIG
#pragma config FOSC = INTRCCLK // Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // MCLR Pin Function Select bit (MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Selection bits (BOR enabled)
#pragma config IESO = ON // Internal External Switchover bit (Internal External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
#define _XTAL_FREQ 8000000
#include <xc.h>
// FORMAT: 0bCCCCCCCCBBBBBBBB / 0b7654321076543210)
#define COL1 0b1100000000000000 // RC5 (connected to cathode on one column of 9 LEDS / LOW == ON)
#define COL2 0b1010000000000000 // RC6 (--||--)
#define COL3 0b0110000000000000 // RC7 (--||--)
#define R1 0b0000010000000000 // RC2 (Connected to anode of one row of 3 LEDS / HIGH == ON)
#define R2 0b0000100000000000 // RC3 (--||--)
#define R3 0b0001000000000000 // RC4 (--||--)
#define Y1 0b0000000010000000 // RB7 (--||--)
#define Y2 0b0000000100000000 // RC0 (--||--)
#define Y3 0b0000001000000000 // RC1 (--||--)
#define W1 0b0000000000010000 // RB4 (--||--)
#define W2 0b0000000000100000 // RB5 (--||--)
#define W3 0b0000000001000000 // RB6 (--||--)
#define NONE 0b0000000000000000 // Turn all lights off
// RA2 is a button that is HIGH when pressed.
signed char animation = 0;
__bit checkInput(void) {
if(PORTA & 0b00000100) {
PORTB = 0b00000000;
PORTC = 0b11100000;
animation += 1;
if(animation > 5) {
animation = 0;
}
while(PORTA & 0b00000100) {
__delay_ms(100);
}
return 1;
}
return 0;
}
void showRow(unsigned int c1, unsigned int c2, unsigned int c3) {
c1 = COL1 | c1;
c2 = COL2 | c2;
c3 = COL3 | c3;
PORTB = (unsigned char)(c1);
PORTC = (unsigned char)(c1 >> 8);
__delay_us(125);
PORTB = (unsigned char)(c2);
PORTC = (unsigned char)(c2 >> 8);
__delay_us(125);
PORTB = (unsigned char)(c3);
PORTC = (unsigned char)(c3 >> 8);
__delay_us(125);
}
void animation1() {
unsigned int c = 0;
unsigned int l = 100;
while(c++ < l) {
showRow(W1 | Y2 | R3,
W2 | Y2 | R2,
W3 | Y2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W2 | Y3,
W2 | Y2 | R1 | R2 | R3,
W2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W3 | R1,
W2 | Y1 | Y2 | Y3 | R2,
W1 | R3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | R2,
W2 | W1 | W3 | Y2 | R2,
Y3 | R2);
}
c = 0; if(checkInput()) { return; }
}
void animation2() {
unsigned int c = 0;
unsigned int l = 100;
while(c++ < l) {
showRow(NONE,
NONE,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(NONE,
R2,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2,
R2,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2 | R3,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2 | R3,
R3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2 | R3,
R3 | R2);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2 | R3,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3,
R2 | R3 | R1,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1,
R2 | R3 | R1,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1,
R2 | R3 | R1 | Y2,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2,
R2 | R3 | R1 | Y2,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2 | Y3,
R3 | R2 | R1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2 | Y3,
R3 | R2 | R1 | Y3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2 | Y3,
R3 | R2 | R1 | Y3 | Y2);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2 | Y3,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3,
R2 | R3 | R1 | Y2 | Y3 | Y1,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1,
R2 | R3 | R1 | Y2 | Y3 | Y1,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W2,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R3 | R2 | R1 | Y3 | Y2 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R3 | R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
Y2 | Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y2 | Y3 | Y1 | W3 | W2 | W1,
Y2 | Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y2 | Y3 | Y1 | W3 | W2 | W1,
Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y3 | Y1 | W3 | W2 | W1,
Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
Y3 | Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
Y1 | W2 | W3 | W1,
Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
Y1 | W2 | W3 | W1,
Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
Y1 | W2 | W3 | W1,
Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
Y1 | W2 | W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(Y1 | W3 | W2 | W1,
W2 | W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W3 | W2 | W1,
W2 | W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W3 | W2 | W1,
W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W3 | W1,
W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
W3 | W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
W1,
W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
W1,
W2 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
W1,
W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
W1,
NONE);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(W1,
NONE,
NONE);
}
c = 0; if(checkInput()) { return; }
}
void animation3() {
unsigned int c = 0;
unsigned int l = 100;
while(c++ < l) {
showRow(R1 | R2 | R3 | W1,
R1 | R2 | R3 | Y2 | W2 | Y3,
R1 | R2 | Y3 | W3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2,
R1 | R2 | R3,
R1 | R2 | R3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2 | Y3,
R1 | R2 | R3 | Y3,
R2 | R3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2 | Y3,
R1 | R2 | R3 | Y3 | Y1,
R1 | R2 | R3 | Y1 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | Y2 | Y3 | W2,
R1 | R2 | R3 | Y3 | Y1 | W3,
R1 | R2 | R3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y3 | W3,
R1 | R2 | R3 | Y1 | W3 | W1,
R1 | R2 | R3 | Y3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | W3 | Y2,
R1 | R2 | R3 | W1,
R1 | R2 | R3 | Y3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | Y2 | W3,
R1 | R2 | R3 | Y3,
R1 | R2 | R3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2 | Y1,
R1 | R2 | R3 | W3 | Y2,
R1 | R2 | R3 | Y3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2 | Y1 | W2,
R1 | R2 | R3 | Y2 ,
R1 | R2 | Y3 | W3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | W1,
R1 | R2 | R3 | Y2 | W2 | Y3,
R1 | R2 | Y3 | W3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1,
R1 | R2 | R3 | Y3 | W3,
R1 | R2 | Y3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1,
R1 | R2 | R3,
R1 | R2 | R3 | Y2);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1 | Y3,
R1 | R2 | R3 | Y1,
R2 | R3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1 | Y3,
R1 | R2 | R3 | Y1 | Y2,
R1 | R2 | R3 | Y1 | W2);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | Y2 | Y3 | W2,
R1 | R2 | R3 | Y1 | W2,
R1 | R2 | R3 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y3 | W3,
R1 | R2 | R3 | Y3 | W2 | W1,
R1 | R2 | R3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | W3 | Y2,
R1 | R2 | R3 | W3,
R1 | R2 | R3 | Y1 | W1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R2 | R3 | Y2 | W2,
R1 | R2 | R3 | Y1,
R1 | R2 | R3 | Y3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1,
R1 | R2 | R3 | W3 | Y2,
R1 | R2 | R3 | W3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y2 | Y3 | W1,
R1 | R2 | R3 | Y2 ,
R1 | R2 | Y3 | W3);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | W3,
R1 | R2 | R3 | W2 | Y3,
R1 | R2 | Y3 | Y1);
}
c = 0; if(checkInput()) { return; }
while(c++ < l) {
showRow(R1 | R2 | R3 | Y1,
R1 | R2 | R3 | Y3 | W3,
R1 | R2 | Y3 | W1);
}
c = 0; if(checkInput()) { return; }
}
void animation4() {
unsigned int c = 0;
for(short col = 0; col < 4; col++) {
for(short i = 8; i >= 0; i--) {
while(c++ < (9-i)*3) {
showRow(R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3,
R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3,
R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3);
PORTB = 0b00000000;
PORTC = 0b11100000;
for(int x=0; x<i*i; x++) {
__delay_us(20);
}
}
c = 0; if(checkInput()) { return; }
}
for(short i = 0; i <= 8; i++) {
while(c++ < (9-i)*3) {
showRow(R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3,
R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3,
R1 | R2 | R3 | Y1 | Y2 | Y3 | W1 | W2 | W3);
PORTB = 0b00000000;
PORTC = 0b11100000;
for(int x=0; x<i*i; x++) {
__delay_us(20);
}
}
c = 0; if(checkInput()) { return; }
}
}
}
void static_mode() {
unsigned int c = 0;
unsigned int l = 100;
while(c++ < l) {
showRow(R2 | R3 | R1 | Y2 | Y3 | Y1 | W3 | W2 | W1,
R2 | R3 | R1 | Y2 | Y3 | Y1 | W2 | W3 | W1,
R3 | R2 | R1 | Y3 | Y2 | Y1 | W2 | W3 | W1);
}
c = 0; if(checkInput()) { return; }
}
void off_mode() {
checkInput();
}
void main(void) {
ANSEL = 0x00;
TRISA = 0b00000100;
TRISB = 0b00000000;
TRISC = 0b00000000;
while(1) {
if(animation == 0) {
animation1();
} else if(animation == 1) {
animation2();
} else if(animation == 2) {
animation3();
} else if(animation == 3) {
animation4();
} else if(animation == 4) {
static_mode();
} else {
off_mode();
}
}
return;
}