diff --git a/README.md b/README.md index 4fc8407..76ecda4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,21 @@ # AVR Projects -This repository holds my AVR projects. They're mostly too small to be worth a separate repository. +*This repository contains all my AVR projects.* -Any code here is free to use in your projects, according to the MIT license. \ No newline at end of file +Most are in C, to be compiled with `avr-gcc`. There's always a `Makefile` that should take care of it. + +## Hardware + +Some projects are for `ATtiny13` or `ATtiny2313`, some bigger ones are for *Arduino Pro Mini*, +but in plain C, not the ugly Arduino C/C++ hybrid. + +I use the Arduino Pro Mini, because it's the cheapest way to get an `ATmega238P`, already with +a nice breakout board, crystal and everything. They can be purchased on eBay for under $3 (USD)! + +## Repo contents + +- Current W.I.P. projects & *latest library code* is in **devel/**. +- Old, not too useful projects are in **archive/** +- Good and finished projects are in **projects/** + +Feel free to use any of my code :o) diff --git a/ASM_OLD/DS1820/RGB teploměr krok 10/ds1820LEDk10.asm b/archive/000000_asm_old/DS1820/RGB teplomer krok 10/ds1820LEDk10.asm similarity index 100% rename from ASM_OLD/DS1820/RGB teploměr krok 10/ds1820LEDk10.asm rename to archive/000000_asm_old/DS1820/RGB teplomer krok 10/ds1820LEDk10.asm diff --git a/ASM_OLD/DS1820/RGB teploměr krok 20/ds1820LEDk20.asm b/archive/000000_asm_old/DS1820/RGB teplomer krok 20/ds1820LEDk20.asm similarity index 100% rename from ASM_OLD/DS1820/RGB teploměr krok 20/ds1820LEDk20.asm rename to archive/000000_asm_old/DS1820/RGB teplomer krok 20/ds1820LEDk20.asm diff --git a/ASM_OLD/DS1820/Univerzal OneWire/ds1820u.asm b/archive/000000_asm_old/DS1820/Univerzal OneWire/ds1820u.asm similarity index 100% rename from ASM_OLD/DS1820/Univerzal OneWire/ds1820u.asm rename to archive/000000_asm_old/DS1820/Univerzal OneWire/ds1820u.asm diff --git a/ASM_OLD/DS1820/schema/PB250219.JPG b/archive/000000_asm_old/DS1820/schema/PB250219.JPG similarity index 100% rename from ASM_OLD/DS1820/schema/PB250219.JPG rename to archive/000000_asm_old/DS1820/schema/PB250219.JPG diff --git a/ASM_OLD/DS1820/schema/PB250221.JPG b/archive/000000_asm_old/DS1820/schema/PB250221.JPG similarity index 100% rename from ASM_OLD/DS1820/schema/PB250221.JPG rename to archive/000000_asm_old/DS1820/schema/PB250221.JPG diff --git a/ASM_OLD/DS1820/schema/PB250223.JPG b/archive/000000_asm_old/DS1820/schema/PB250223.JPG similarity index 100% rename from ASM_OLD/DS1820/schema/PB250223.JPG rename to archive/000000_asm_old/DS1820/schema/PB250223.JPG diff --git a/ASM_OLD/DS1820/schema/obvod.png b/archive/000000_asm_old/DS1820/schema/obvod.png similarity index 100% rename from ASM_OLD/DS1820/schema/obvod.png rename to archive/000000_asm_old/DS1820/schema/obvod.png diff --git a/ASM_OLD/DS1820/schema/sensor.jpg b/archive/000000_asm_old/DS1820/schema/sensor.jpg similarity index 100% rename from ASM_OLD/DS1820/schema/sensor.jpg rename to archive/000000_asm_old/DS1820/schema/sensor.jpg diff --git a/ASM_OLD/Detektor tmy s 1 led/tma.asm b/archive/000000_asm_old/Detektor tmy s 1 led/tma.asm similarity index 100% rename from ASM_OLD/Detektor tmy s 1 led/tma.asm rename to archive/000000_asm_old/Detektor tmy s 1 led/tma.asm diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws diff --git a/ASM_OLD/EEPROM/t13-EEPROM_nahoda/labels.tmp b/archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/labels.tmp similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_nahoda/labels.tmp rename to archive/000000_asm_old/EEPROM/t13-EEPROM_nahoda/labels.tmp diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/AvrBuild.bat b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/AvrBuild.bat similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/AvrBuild.bat rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/AvrBuild.bat diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.aps b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.aps similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.aps rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.aps diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.asm b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.asm similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.asm rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.asm diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.eep b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.eep similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.eep rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.eep diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.map b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.map similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/EEPROM_read.map rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/EEPROM_read.map diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/eeprom_read.aws b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/eeprom_read.aws similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/eeprom_read.aws rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/eeprom_read.aws diff --git a/ASM_OLD/EEPROM/t13-EEPROM_read/labels.tmp b/archive/000000_asm_old/EEPROM/t13-EEPROM_read/labels.tmp similarity index 100% rename from ASM_OLD/EEPROM/t13-EEPROM_read/labels.tmp rename to archive/000000_asm_old/EEPROM/t13-EEPROM_read/labels.tmp diff --git a/ASM_OLD/HD44780/lcd_default.asm b/archive/000000_asm_old/HD44780/lcd_default.asm similarity index 100% rename from ASM_OLD/HD44780/lcd_default.asm rename to archive/000000_asm_old/HD44780/lcd_default.asm diff --git a/ASM_OLD/HD44780/pokusy/cocacola.asm b/archive/000000_asm_old/HD44780/pokusy/cocacola.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/cocacola.asm rename to archive/000000_asm_old/HD44780/pokusy/cocacola.asm diff --git a/ASM_OLD/HD44780/pokusy/geocache.asm b/archive/000000_asm_old/HD44780/pokusy/geocache.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/geocache.asm rename to archive/000000_asm_old/HD44780/pokusy/geocache.asm diff --git a/ASM_OLD/HD44780/pokusy/krokodyl.asm b/archive/000000_asm_old/HD44780/pokusy/krokodyl.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/krokodyl.asm rename to archive/000000_asm_old/HD44780/pokusy/krokodyl.asm diff --git a/ASM_OLD/HD44780/pokusy/krokodyl_real.asm b/archive/000000_asm_old/HD44780/pokusy/krokodyl_real.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/krokodyl_real.asm rename to archive/000000_asm_old/HD44780/pokusy/krokodyl_real.asm diff --git a/ASM_OLD/HD44780/pokusy/lcd.asm b/archive/000000_asm_old/HD44780/pokusy/lcd.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/lcd.asm rename to archive/000000_asm_old/HD44780/pokusy/lcd.asm diff --git a/ASM_OLD/HD44780/pokusy/lcd_default_4row.asm b/archive/000000_asm_old/HD44780/pokusy/lcd_default_4row.asm similarity index 100% rename from ASM_OLD/HD44780/pokusy/lcd_default_4row.asm rename to archive/000000_asm_old/HD44780/pokusy/lcd_default_4row.asm diff --git a/ASM_OLD/IR insect/prijimac 36kHz - modulace/rcvm.asm b/archive/000000_asm_old/IR insect/prijimac 36kHz - modulace/rcvm.asm similarity index 100% rename from ASM_OLD/IR insect/prijimac 36kHz - modulace/rcvm.asm rename to archive/000000_asm_old/IR insect/prijimac 36kHz - modulace/rcvm.asm diff --git a/ASM_OLD/IR insect/prijimac 36kHz - ochrana x zakmitum - preklapeni/delic.asm b/archive/000000_asm_old/IR insect/prijimac 36kHz - ochrana x zakmitum - preklapeni/delic.asm similarity index 100% rename from ASM_OLD/IR insect/prijimac 36kHz - ochrana x zakmitum - preklapeni/delic.asm rename to archive/000000_asm_old/IR insect/prijimac 36kHz - ochrana x zakmitum - preklapeni/delic.asm diff --git a/ASM_OLD/IR insect/prijimac 36kHz - ochrana x zakmitum - prosty/tlac.asm b/archive/000000_asm_old/IR insect/prijimac 36kHz - ochrana x zakmitum - prosty/tlac.asm similarity index 100% rename from ASM_OLD/IR insect/prijimac 36kHz - ochrana x zakmitum - prosty/tlac.asm rename to archive/000000_asm_old/IR insect/prijimac 36kHz - ochrana x zakmitum - prosty/tlac.asm diff --git a/ASM_OLD/IR insect/switch controlled/brouk-sw.asm b/archive/000000_asm_old/IR insect/switch controlled/brouk-sw.asm similarity index 100% rename from ASM_OLD/IR insect/switch controlled/brouk-sw.asm rename to archive/000000_asm_old/IR insect/switch controlled/brouk-sw.asm diff --git a/ASM_OLD/IR insect/vysilac 36kHz - modulace/36kHzm.asm b/archive/000000_asm_old/IR insect/vysilac 36kHz - modulace/36kHzm.asm similarity index 100% rename from ASM_OLD/IR insect/vysilac 36kHz - modulace/36kHzm.asm rename to archive/000000_asm_old/IR insect/vysilac 36kHz - modulace/36kHzm.asm diff --git a/ASM_OLD/IR insect/vysilac 36kHz/36kHz.asm b/archive/000000_asm_old/IR insect/vysilac 36kHz/36kHz.asm similarity index 100% rename from ASM_OLD/IR insect/vysilac 36kHz/36kHz.asm rename to archive/000000_asm_old/IR insect/vysilac 36kHz/36kHz.asm diff --git a/ASM_OLD/KOSTKA-nelinearni/a/dice2a.asm b/archive/000000_asm_old/KOSTKA-nelinearni/a/dice2a.asm similarity index 100% rename from ASM_OLD/KOSTKA-nelinearni/a/dice2a.asm rename to archive/000000_asm_old/KOSTKA-nelinearni/a/dice2a.asm diff --git a/ASM_OLD/KOSTKA-nelinearni/dice2b.asm b/archive/000000_asm_old/KOSTKA-nelinearni/dice2b.asm similarity index 100% rename from ASM_OLD/KOSTKA-nelinearni/dice2b.asm rename to archive/000000_asm_old/KOSTKA-nelinearni/dice2b.asm diff --git a/ASM_OLD/KOSTKA-nelinearni/dice2c.asm b/archive/000000_asm_old/KOSTKA-nelinearni/dice2c.asm similarity index 100% rename from ASM_OLD/KOSTKA-nelinearni/dice2c.asm rename to archive/000000_asm_old/KOSTKA-nelinearni/dice2c.asm diff --git a/ASM_OLD/KOSTKA/dice.asm b/archive/000000_asm_old/KOSTKA/dice.asm similarity index 100% rename from ASM_OLD/KOSTKA/dice.asm rename to archive/000000_asm_old/KOSTKA/dice.asm diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/AvrBuild.bat b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/AvrBuild.bat similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/AvrBuild.bat rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/AvrBuild.bat diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.aps b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.aps similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.aps rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.aps diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.asm b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.asm similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.asm rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.asm diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.map b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.map similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.map rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED.map diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED2 b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED2 similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED2 rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_LED2 diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_led.aws b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_led.aws similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/efekty_led.aws rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/efekty_led.aws diff --git a/ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/labels.tmp b/archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/labels.tmp similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16-HAD_leze/labels.tmp rename to archive/000000_asm_old/OBSLUHA_PORTU/m16-HAD_leze/labels.tmp diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/AvrBuild.bat b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/AvrBuild.bat similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/AvrBuild.bat rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/AvrBuild.bat diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.aps b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.aps similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.aps rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.aps diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.asm b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.asm similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.asm rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.asm diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.map b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.map similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/LED_display.map rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/LED_display.map diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/labels.tmp b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/labels.tmp similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/labels.tmp rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/labels.tmp diff --git a/ASM_OLD/OBSLUHA_PORTU/m16_LED_display/led_display.aws b/archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/led_display.aws similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/m16_LED_display/led_display.aws rename to archive/000000_asm_old/OBSLUHA_PORTU/m16_LED_display/led_display.aws diff --git a/ASM_OLD/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.asm b/archive/000000_asm_old/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.asm similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.asm rename to archive/000000_asm_old/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.asm diff --git a/ASM_OLD/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.map b/archive/000000_asm_old/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.map similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.map rename to archive/000000_asm_old/OBSLUHA_PORTU/t13-Navesti_vlak/pokus.map diff --git a/ASM_OLD/OBSLUHA_PORTU/t13-Vstup_button/Vstup_button.asm b/archive/000000_asm_old/OBSLUHA_PORTU/t13-Vstup_button/Vstup_button.asm similarity index 100% rename from ASM_OLD/OBSLUHA_PORTU/t13-Vstup_button/Vstup_button.asm rename to archive/000000_asm_old/OBSLUHA_PORTU/t13-Vstup_button/Vstup_button.asm diff --git a/ASM_OLD/ONDIS displej 8 R-G ledek/ondis01.asm b/archive/000000_asm_old/ONDIS displej 8 R-G ledek/ondis01.asm similarity index 100% rename from ASM_OLD/ONDIS displej 8 R-G ledek/ondis01.asm rename to archive/000000_asm_old/ONDIS displej 8 R-G ledek/ondis01.asm diff --git a/ASM_OLD/SETI/01/seti.asm b/archive/000000_asm_old/SETI/01/seti.asm similarity index 100% rename from ASM_OLD/SETI/01/seti.asm rename to archive/000000_asm_old/SETI/01/seti.asm diff --git a/ASM_OLD/SETI/02/seti2.asm b/archive/000000_asm_old/SETI/02/seti2.asm similarity index 100% rename from ASM_OLD/SETI/02/seti2.asm rename to archive/000000_asm_old/SETI/02/seti2.asm diff --git a/ASM_OLD/SETI/03/seti3.asm b/archive/000000_asm_old/SETI/03/seti3.asm similarity index 100% rename from ASM_OLD/SETI/03/seti3.asm rename to archive/000000_asm_old/SETI/03/seti3.asm diff --git a/ASM_OLD/SETI/04/seti4.asm b/archive/000000_asm_old/SETI/04/seti4.asm similarity index 100% rename from ASM_OLD/SETI/04/seti4.asm rename to archive/000000_asm_old/SETI/04/seti4.asm diff --git a/ASM_OLD/SETI/seti - pípač pro Punťu/punta.asm b/archive/000000_asm_old/SETI/seti - morse pip/punta.asm similarity index 100% rename from ASM_OLD/SETI/seti - pípač pro Punťu/punta.asm rename to archive/000000_asm_old/SETI/seti - morse pip/punta.asm diff --git a/ASM_OLD/SETI/seti5.asm b/archive/000000_asm_old/SETI/seti5.asm similarity index 100% rename from ASM_OLD/SETI/seti5.asm rename to archive/000000_asm_old/SETI/seti5.asm diff --git a/ASM_OLD/Světelné efekty/Blikac prolinani 5/bezici-svetlo-prol.asm b/archive/000000_asm_old/Svetelne efekty/Blikac prolinani 5/bezici-svetlo-prol.asm similarity index 100% rename from ASM_OLD/Světelné efekty/Blikac prolinani 5/bezici-svetlo-prol.asm rename to archive/000000_asm_old/Svetelne efekty/Blikac prolinani 5/bezici-svetlo-prol.asm diff --git a/ASM_OLD/Světelné efekty/Blikač 2 led/pokus.asm b/archive/000000_asm_old/Svetelne efekty/Blink 2/pokus.asm similarity index 100% rename from ASM_OLD/Světelné efekty/Blikač 2 led/pokus.asm rename to archive/000000_asm_old/Svetelne efekty/Blink 2/pokus.asm diff --git a/ASM_OLD/Světelné efekty/Blikač 2 led/pokus.map b/archive/000000_asm_old/Svetelne efekty/Blink 2/pokus.map similarity index 100% rename from ASM_OLD/Světelné efekty/Blikač 2 led/pokus.map rename to archive/000000_asm_old/Svetelne efekty/Blink 2/pokus.map diff --git a/ASM_OLD/Světelné efekty/Pulzující LED/pulzovani.asm b/archive/000000_asm_old/Svetelne efekty/Pulse led/pulzovani.asm similarity index 100% rename from ASM_OLD/Světelné efekty/Pulzující LED/pulzovani.asm rename to archive/000000_asm_old/Svetelne efekty/Pulse led/pulzovani.asm diff --git a/ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 12 barev/rgbdrivch12.asm b/archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 12 barev/rgbdrivch12.asm similarity index 100% rename from ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 12 barev/rgbdrivch12.asm rename to archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 12 barev/rgbdrivch12.asm diff --git a/ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 6 barev/rgbdrivch.asm b/archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 6 barev/rgbdrivch.asm similarity index 100% rename from ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 6 barev/rgbdrivch.asm rename to archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 6 barev/rgbdrivch.asm diff --git a/ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 9 barev/rgbdrivch9.asm b/archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 9 barev/rgbdrivch9.asm similarity index 100% rename from ASM_OLD/Světelné efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 9 barev/rgbdrivch9.asm rename to archive/000000_asm_old/Svetelne efekty/RGB LED efekty/prepinani nekolika odstinu/prepinani 9 barev/rgbdrivch9.asm diff --git a/ASM_OLD/bomba/bomba.asm b/archive/000000_asm_old/bomba/bomba.asm similarity index 100% rename from ASM_OLD/bomba/bomba.asm rename to archive/000000_asm_old/bomba/bomba.asm diff --git a/ASM_OLD/bomba/tmp/bomba.asm b/archive/000000_asm_old/bomba/tmp/bomba.asm similarity index 100% rename from ASM_OLD/bomba/tmp/bomba.asm rename to archive/000000_asm_old/bomba/tmp/bomba.asm diff --git a/ASM_OLD/bomba/tmp/bomba2.asm b/archive/000000_asm_old/bomba/tmp/bomba2.asm similarity index 100% rename from ASM_OLD/bomba/tmp/bomba2.asm rename to archive/000000_asm_old/bomba/tmp/bomba2.asm diff --git a/ASM_OLD/bomba/tmp/bomba2b.asm b/archive/000000_asm_old/bomba/tmp/bomba2b.asm similarity index 100% rename from ASM_OLD/bomba/tmp/bomba2b.asm rename to archive/000000_asm_old/bomba/tmp/bomba2b.asm diff --git a/ASM_OLD/bomba/tmp/bomba_mx.asm b/archive/000000_asm_old/bomba/tmp/bomba_mx.asm similarity index 100% rename from ASM_OLD/bomba/tmp/bomba_mx.asm rename to archive/000000_asm_old/bomba/tmp/bomba_mx.asm diff --git a/ASM_OLD/pokusy/slowdown/sldn.asm b/archive/000000_asm_old/pokusy/slowdown/sldn.asm similarity index 100% rename from ASM_OLD/pokusy/slowdown/sldn.asm rename to archive/000000_asm_old/pokusy/slowdown/sldn.asm diff --git a/ASM_OLD/t13_PASTICKA_morse/t13_PASTICKA_morse.asm b/archive/000000_asm_old/t13_PASTICKA_morse/t13_PASTICKA_morse.asm similarity index 100% rename from ASM_OLD/t13_PASTICKA_morse/t13_PASTICKA_morse.asm rename to archive/000000_asm_old/t13_PASTICKA_morse/t13_PASTICKA_morse.asm diff --git a/ASM_OLD/timer/citac/timer.asm b/archive/000000_asm_old/timer/citac/timer.asm similarity index 100% rename from ASM_OLD/timer/citac/timer.asm rename to archive/000000_asm_old/timer/citac/timer.asm diff --git a/ASM_OLD/utility/3-kanalova simulovana PWM/rgbdriv.asm b/archive/000000_asm_old/utility/3-kanalova simulovana PWM/rgbdriv.asm similarity index 100% rename from ASM_OLD/utility/3-kanalova simulovana PWM/rgbdriv.asm rename to archive/000000_asm_old/utility/3-kanalova simulovana PWM/rgbdriv.asm diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/AvrBuild.bat diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.aps diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.asm diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.eep diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/EEPROM_nahoda.map diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/eeprom_nahoda.aws diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/labels.tmp b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/labels.tmp similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_nahoda/labels.tmp rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_nahoda/labels.tmp diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/AvrBuild.bat b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/AvrBuild.bat similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/AvrBuild.bat rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/AvrBuild.bat diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.aps b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.aps similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.aps rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.aps diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.asm b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.asm similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.asm rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.asm diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.eep b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.eep similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.eep rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.eep diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.map b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.map similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/EEPROM_read.map rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/EEPROM_read.map diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/eeprom_read.aws b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/eeprom_read.aws similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/eeprom_read.aws rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/eeprom_read.aws diff --git a/ASM_OLD/utility/EEPROM/t13-EEPROM_read/labels.tmp b/archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/labels.tmp similarity index 100% rename from ASM_OLD/utility/EEPROM/t13-EEPROM_read/labels.tmp rename to archive/000000_asm_old/utility/EEPROM/t13-EEPROM_read/labels.tmp diff --git a/ASM_OLD/utility/citac/timer.asm b/archive/000000_asm_old/utility/citac/timer.asm similarity index 100% rename from ASM_OLD/utility/citac/timer.asm rename to archive/000000_asm_old/utility/citac/timer.asm diff --git a/ASM_OLD/utility/osetreni zakmitu tlacitek/Vstup_button.asm b/archive/000000_asm_old/utility/osetreni zakmitu tlacitek/Vstup_button.asm similarity index 100% rename from ASM_OLD/utility/osetreni zakmitu tlacitek/Vstup_button.asm rename to archive/000000_asm_old/utility/osetreni zakmitu tlacitek/Vstup_button.asm diff --git a/bomb-countdown/main.c b/archive/000000_bomb-countdown/main.c similarity index 100% rename from bomb-countdown/main.c rename to archive/000000_bomb-countdown/main.c diff --git a/bomb-countdown/makefile b/archive/000000_bomb-countdown/makefile similarity index 100% rename from bomb-countdown/makefile rename to archive/000000_bomb-countdown/makefile diff --git a/rgb-led-strip/arduino-ws-static-rainbow/Makefile b/archive/141214_rgb-strip-static-rainbow/Makefile similarity index 100% rename from rgb-led-strip/arduino-ws-static-rainbow/Makefile rename to archive/141214_rgb-strip-static-rainbow/Makefile diff --git a/rgb-led-strip/arduino-ws-static-rainbow/arduino_pins.h b/archive/141214_rgb-strip-static-rainbow/arduino_pins.h similarity index 100% rename from rgb-led-strip/arduino-ws-static-rainbow/arduino_pins.h rename to archive/141214_rgb-strip-static-rainbow/arduino_pins.h diff --git a/rgb-led-strip/arduino-ws-static-rainbow/main.c b/archive/141214_rgb-strip-static-rainbow/main.c similarity index 100% rename from rgb-led-strip/arduino-ws-static-rainbow/main.c rename to archive/141214_rgb-strip-static-rainbow/main.c diff --git a/rgb-led-strip/arduino-ws-static-rainbow/utils.h b/archive/141214_rgb-strip-static-rainbow/utils.h similarity index 100% rename from rgb-led-strip/arduino-ws-static-rainbow/utils.h rename to archive/141214_rgb-strip-static-rainbow/utils.h diff --git a/pov-led-globe/globe-fixed/Makefile b/archive/141219_korec-led-globe/globe-fixed/Makefile similarity index 100% rename from pov-led-globe/globe-fixed/Makefile rename to archive/141219_korec-led-globe/globe-fixed/Makefile diff --git a/pov-led-globe/globe-fixed/image/README.txt b/archive/141219_korec-led-globe/globe-fixed/image/README.txt similarity index 100% rename from pov-led-globe/globe-fixed/image/README.txt rename to archive/141219_korec-led-globe/globe-fixed/image/README.txt diff --git a/pov-led-globe/globe-fixed/image/butt.h b/archive/141219_korec-led-globe/globe-fixed/image/butt.h similarity index 100% rename from pov-led-globe/globe-fixed/image/butt.h rename to archive/141219_korec-led-globe/globe-fixed/image/butt.h diff --git a/pov-led-globe/globe-fixed/image/getbytes.py b/archive/141219_korec-led-globe/globe-fixed/image/getbytes.py similarity index 100% rename from pov-led-globe/globe-fixed/image/getbytes.py rename to archive/141219_korec-led-globe/globe-fixed/image/getbytes.py diff --git a/pov-led-globe/globe-fixed/image/globus.h b/archive/141219_korec-led-globe/globe-fixed/image/globus.h similarity index 100% rename from pov-led-globe/globe-fixed/image/globus.h rename to archive/141219_korec-led-globe/globe-fixed/image/globus.h diff --git a/pov-led-globe/globe-fixed/image/logo16.h b/archive/141219_korec-led-globe/globe-fixed/image/logo16.h similarity index 100% rename from pov-led-globe/globe-fixed/image/logo16.h rename to archive/141219_korec-led-globe/globe-fixed/image/logo16.h diff --git a/pov-led-globe/globe-fixed/image/logo16.xcf b/archive/141219_korec-led-globe/globe-fixed/image/logo16.xcf similarity index 100% rename from pov-led-globe/globe-fixed/image/logo16.xcf rename to archive/141219_korec-led-globe/globe-fixed/image/logo16.xcf diff --git a/pov-led-globe/globe-fixed/image/logo32.h b/archive/141219_korec-led-globe/globe-fixed/image/logo32.h similarity index 100% rename from pov-led-globe/globe-fixed/image/logo32.h rename to archive/141219_korec-led-globe/globe-fixed/image/logo32.h diff --git a/pov-led-globe/globe-fixed/image/logo32.xcf b/archive/141219_korec-led-globe/globe-fixed/image/logo32.xcf similarity index 100% rename from pov-led-globe/globe-fixed/image/logo32.xcf rename to archive/141219_korec-led-globe/globe-fixed/image/logo32.xcf diff --git a/pov-led-globe/globe-fixed/image/pig.h b/archive/141219_korec-led-globe/globe-fixed/image/pig.h similarity index 100% rename from pov-led-globe/globe-fixed/image/pig.h rename to archive/141219_korec-led-globe/globe-fixed/image/pig.h diff --git a/pov-led-globe/globe-fixed/image/pig16.h b/archive/141219_korec-led-globe/globe-fixed/image/pig16.h similarity index 100% rename from pov-led-globe/globe-fixed/image/pig16.h rename to archive/141219_korec-led-globe/globe-fixed/image/pig16.h diff --git a/pov-led-globe/globe-fixed/image/pig16.xcf b/archive/141219_korec-led-globe/globe-fixed/image/pig16.xcf similarity index 100% rename from pov-led-globe/globe-fixed/image/pig16.xcf rename to archive/141219_korec-led-globe/globe-fixed/image/pig16.xcf diff --git a/pov-led-globe/globe-fixed/image/snowflake.h b/archive/141219_korec-led-globe/globe-fixed/image/snowflake.h similarity index 100% rename from pov-led-globe/globe-fixed/image/snowflake.h rename to archive/141219_korec-led-globe/globe-fixed/image/snowflake.h diff --git a/pov-led-globe/globe-fixed/image/snowflake.xcf b/archive/141219_korec-led-globe/globe-fixed/image/snowflake.xcf similarity index 100% rename from pov-led-globe/globe-fixed/image/snowflake.xcf rename to archive/141219_korec-led-globe/globe-fixed/image/snowflake.xcf diff --git a/pov-led-globe/globe-fixed/image_globus32.h b/archive/141219_korec-led-globe/globe-fixed/image_globus32.h similarity index 100% rename from pov-led-globe/globe-fixed/image_globus32.h rename to archive/141219_korec-led-globe/globe-fixed/image_globus32.h diff --git a/pov-led-globe/globe-fixed/image_globus32_reverse.h b/archive/141219_korec-led-globe/globe-fixed/image_globus32_reverse.h similarity index 100% rename from pov-led-globe/globe-fixed/image_globus32_reverse.h rename to archive/141219_korec-led-globe/globe-fixed/image_globus32_reverse.h diff --git a/pov-led-globe/globe-fixed/image_logo16.h b/archive/141219_korec-led-globe/globe-fixed/image_logo16.h similarity index 100% rename from pov-led-globe/globe-fixed/image_logo16.h rename to archive/141219_korec-led-globe/globe-fixed/image_logo16.h diff --git a/pov-led-globe/globe-fixed/image_logo32.h b/archive/141219_korec-led-globe/globe-fixed/image_logo32.h similarity index 100% rename from pov-led-globe/globe-fixed/image_logo32.h rename to archive/141219_korec-led-globe/globe-fixed/image_logo32.h diff --git a/pov-led-globe/globe-fixed/image_pig16.h b/archive/141219_korec-led-globe/globe-fixed/image_pig16.h similarity index 100% rename from pov-led-globe/globe-fixed/image_pig16.h rename to archive/141219_korec-led-globe/globe-fixed/image_pig16.h diff --git a/pov-led-globe/globe-fixed/image_snowflake16.h b/archive/141219_korec-led-globe/globe-fixed/image_snowflake16.h similarity index 100% rename from pov-led-globe/globe-fixed/image_snowflake16.h rename to archive/141219_korec-led-globe/globe-fixed/image_snowflake16.h diff --git a/pov-led-globe/globe-fixed/main.c b/archive/141219_korec-led-globe/globe-fixed/main.c similarity index 100% rename from pov-led-globe/globe-fixed/main.c rename to archive/141219_korec-led-globe/globe-fixed/main.c diff --git a/pov-led-globe/globe-fixed/main.c_1 b/archive/141219_korec-led-globe/globe-fixed/main.c_1 similarity index 100% rename from pov-led-globe/globe-fixed/main.c_1 rename to archive/141219_korec-led-globe/globe-fixed/main.c_1 diff --git a/pov-led-globe/globe-fixed/utils.h b/archive/141219_korec-led-globe/globe-fixed/utils.h similarity index 100% rename from pov-led-globe/globe-fixed/utils.h rename to archive/141219_korec-led-globe/globe-fixed/utils.h diff --git a/pov-led-globe/globe-timed-experimental/Makefile b/archive/141219_korec-led-globe/globe-timed-experimental/Makefile similarity index 100% rename from pov-led-globe/globe-timed-experimental/Makefile rename to archive/141219_korec-led-globe/globe-timed-experimental/Makefile diff --git a/pov-led-globe/globe-timed-experimental/image/README.txt b/archive/141219_korec-led-globe/globe-timed-experimental/image/README.txt similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/README.txt rename to archive/141219_korec-led-globe/globe-timed-experimental/image/README.txt diff --git a/pov-led-globe/globe-timed-experimental/image/aliensflip16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/aliensflip16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/aliensflip16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/aliensflip16.h diff --git a/pov-led-globe/globe-timed-experimental/image/butt.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/butt.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/butt.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/butt.h diff --git a/pov-led-globe/globe-timed-experimental/image/checker3264.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/checker3264.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264.h diff --git a/pov-led-globe/globe-timed-experimental/image/checker3264.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/checker3264.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/checker3264numbers.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264numbers.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/checker3264numbers.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264numbers.h diff --git a/pov-led-globe/globe-timed-experimental/image/checker3264numbers.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264numbers.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/checker3264numbers.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/checker3264numbers.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/getbytes.py b/archive/141219_korec-led-globe/globe-timed-experimental/image/getbytes.py similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/getbytes.py rename to archive/141219_korec-led-globe/globe-timed-experimental/image/getbytes.py diff --git a/pov-led-globe/globe-timed-experimental/image/globus.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/globus.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/globus.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/globus.h diff --git a/pov-led-globe/globe-timed-experimental/image/globus.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/globus.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/globus.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/globus.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/logo16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/logo16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/logo16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/logo16.h diff --git a/pov-led-globe/globe-timed-experimental/image/logo16.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/logo16.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/logo16.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/logo16.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/logo32.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/logo32.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/logo32.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/logo32.h diff --git a/pov-led-globe/globe-timed-experimental/image/logo32.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/logo32.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/logo32.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/logo32.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/pig.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/pig.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/pig.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/pig.h diff --git a/pov-led-globe/globe-timed-experimental/image/pig16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/pig16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/pig16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/pig16.h diff --git a/pov-led-globe/globe-timed-experimental/image/pig16.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/pig16.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/pig16.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/pig16.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/snowflake.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/snowflake.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/snowflake.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/snowflake.h diff --git a/pov-led-globe/globe-timed-experimental/image/snowflake.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/snowflake.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/snowflake.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/snowflake.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/some-aliens.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/some-aliens.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/some-aliens.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/some-aliens.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/test_narrow.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/test_narrow.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/test_narrow.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/test_narrow.h diff --git a/pov-led-globe/globe-timed-experimental/image/test_narrow.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/test_narrow.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/test_narrow.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/test_narrow.xcf diff --git a/pov-led-globe/globe-timed-experimental/image/test_wide.h b/archive/141219_korec-led-globe/globe-timed-experimental/image/test_wide.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/test_wide.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image/test_wide.h diff --git a/pov-led-globe/globe-timed-experimental/image/test_wide.xcf b/archive/141219_korec-led-globe/globe-timed-experimental/image/test_wide.xcf similarity index 100% rename from pov-led-globe/globe-timed-experimental/image/test_wide.xcf rename to archive/141219_korec-led-globe/globe-timed-experimental/image/test_wide.xcf diff --git a/pov-led-globe/globe-timed-experimental/image_aliensflip16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_aliensflip16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_aliensflip16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_aliensflip16.h diff --git a/pov-led-globe/globe-timed-experimental/image_chk3264.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_chk3264.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_chk3264.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_chk3264.h diff --git a/pov-led-globe/globe-timed-experimental/image_chk3264numbers.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_chk3264numbers.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_chk3264numbers.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_chk3264numbers.h diff --git a/pov-led-globe/globe-timed-experimental/image_globus32.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_globus32.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_globus32.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_globus32.h diff --git a/pov-led-globe/globe-timed-experimental/image_logo16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_logo16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_logo16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_logo16.h diff --git a/pov-led-globe/globe-timed-experimental/image_logo32.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_logo32.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_logo32.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_logo32.h diff --git a/pov-led-globe/globe-timed-experimental/image_pig16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_pig16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_pig16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_pig16.h diff --git a/pov-led-globe/globe-timed-experimental/image_snowflake16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_snowflake16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_snowflake16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_snowflake16.h diff --git a/pov-led-globe/globe-timed-experimental/image_test_narrow16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_test_narrow16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_test_narrow16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_test_narrow16.h diff --git a/pov-led-globe/globe-timed-experimental/image_test_wide16.h b/archive/141219_korec-led-globe/globe-timed-experimental/image_test_wide16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/image_test_wide16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/image_test_wide16.h diff --git a/pov-led-globe/globe-timed-experimental/main.c b/archive/141219_korec-led-globe/globe-timed-experimental/main.c similarity index 100% rename from pov-led-globe/globe-timed-experimental/main.c rename to archive/141219_korec-led-globe/globe-timed-experimental/main.c diff --git a/pov-led-globe/globe-timed-experimental/test_narrow16.h b/archive/141219_korec-led-globe/globe-timed-experimental/test_narrow16.h similarity index 100% rename from pov-led-globe/globe-timed-experimental/test_narrow16.h rename to archive/141219_korec-led-globe/globe-timed-experimental/test_narrow16.h diff --git a/keyboard-lamp/utils.h b/archive/141219_korec-led-globe/globe-timed-experimental/utils.h similarity index 100% rename from keyboard-lamp/utils.h rename to archive/141219_korec-led-globe/globe-timed-experimental/utils.h diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver.c b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver.c similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver.c rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver.c diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver.h b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver.h similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver.h rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver.h diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver2.c b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver2.c similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver2.c rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver2.c diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver2.h b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver2.h similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver2.h rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver2.h diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver3.c b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver3.c similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver3.c rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver3.c diff --git a/rgb-led-strip/ws_driver_legacy/ws_driver3.h b/archive/141221_rgb-strip-ws_driver_legacy/ws_driver3.h similarity index 100% rename from rgb-led-strip/ws_driver_legacy/ws_driver3.h rename to archive/141221_rgb-strip-ws_driver_legacy/ws_driver3.h diff --git a/rgb-led-strip/arduino-ws-gamepad/Makefile b/archive/141222_gamepad-rgb-test/Makefile similarity index 89% rename from rgb-led-strip/arduino-ws-gamepad/Makefile rename to archive/141222_gamepad-rgb-test/Makefile index 385f3eb..82a8c47 100644 --- a/rgb-led-strip/arduino-ws-gamepad/Makefile +++ b/archive/141222_gamepad-rgb-test/Makefile @@ -12,7 +12,7 @@ MAIN = main.c ## If you've split your program into multiple files, ## include the additional .c source (in same directory) here ## (and include the .h files in your foo.c) -LOCAL_SOURCE = lib/ws_driver.c +LOCAL_SOURCE = ## Here you can link to one more directory (and multiple .c files) # EXTRA_SOURCE_DIR = ../AVR-Programming-Library/ @@ -48,19 +48,22 @@ AVRSIZE = avr-size AVRDUDE = sudo avrdude ## Compilation options, type man avr-gcc if you're curious. -CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -Os -I. -I$(EXTRA_SOURCE_DIR) +CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -I. -I$(EXTRA_SOURCE_DIR) CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS += -Wall -Wstrict-prototypes -Wno-main -Wno-strict-prototypes -Wno-comment -CFLAGS += -g2 -ggdb +CFLAGS += -Wall -Wno-main -Wno-strict-prototypes -Wno-comment +CFLAGS += -g2 -Wextra -pedantic -Wfatal-errors CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--relax -CFLAGS += -std=gnu99 + +CFLAGS_BUILD = $(CFLAGS) -Os + # CFLAGS += -lm ## CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf ## CFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf ## Lump target and extra source files together TARGET = $(strip $(basename $(MAIN))) -SRC = $(TARGET).c +SRC1 = $(TARGET).c +SRC = $(SRC1) EXTRA_SOURCE = $(addprefix $(EXTRA_SOURCE_DIR), $(EXTRA_SOURCE_FILES)) SRC += $(EXTRA_SOURCE) SRC += $(LOCAL_SOURCE) @@ -73,12 +76,16 @@ OBJ = $(SRC:.c=.o) ## Generic Makefile targets. (Only .hex file is necessary) all: $(TARGET).hex size +pre: $(TARGET).pre %.hex: %.elf $(OBJCOPY) -R .eeprom -O ihex $< $@ %.elf: $(SRC) - $(CC) $(CFLAGS) $(SRC) --output $@ + $(CC) $(CFLAGS_BUILD) $(SRC) --output $@ + +%.pre: $(SRC1) + $(CC) $(CFLAGS) -E $(SRC1) --output $@ %.eeprom: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ @@ -96,6 +103,7 @@ debug: disassemble: $(TARGET).lst dis: disassemble +lst: disassemble eeprom: $(TARGET).eeprom diff --git a/archive/141222_gamepad-rgb-test/lib/arduino_pins.h b/archive/141222_gamepad-rgb-test/lib/arduino_pins.h new file mode 100644 index 0000000..ca4f4c6 --- /dev/null +++ b/archive/141222_gamepad-rgb-test/lib/arduino_pins.h @@ -0,0 +1,42 @@ +#pragma once + +/** + Pin definitions for Arduino (Pro Mini with ATmega328P) +*/ + +#include "pins.h" + +#define D0 D,0 +#define D1 D,1 +#define D2 D,2 +#define D3 D,3 +#define D4 D,4 +#define D5 D,5 +#define D6 D,6 +#define D7 D,7 +#define D8 B,0 +#define D9 B,1 +#define D10 B,2 + +// MOSI MISO SCK - not good for input +#define D11 B,3 +#define D12 B,4 +#define D13 B,5 + +#define D14 C,0 +#define D15 C,1 +#define D16 C,2 +#define D17 C,3 +#define D18 C,4 +#define D19 C,5 +#define D20 C,6 +#define D21 C,7 + +#define A0 C,0 +#define A1 C,1 +#define A2 C,2 +#define A3 C,3 +#define A4 C,4 +#define A5 C,5 +#define A6 C,6 +#define A7 C,7 diff --git a/archive/141222_gamepad-rgb-test/lib/calc.h b/archive/141222_gamepad-rgb-test/lib/calc.h new file mode 100644 index 0000000..d2602bb --- /dev/null +++ b/archive/141222_gamepad-rgb-test/lib/calc.h @@ -0,0 +1,40 @@ +#pragma once + +/** + General purpose calculation and bit manipulation utilities. +*/ + +// if max, go to zero. Else increment. +#define inc_wrap(var, max) do { if ((var) >= (max)) { (var)=0; } else { (var)++; } } while(0) + +// If zero, go to max. Else decrement, +#define dec_wrap(var, max) do { if ((var) > 0) { (var)--; } else { (var)=(max); } } while(0) + +// Check if value is in range A..B or B..A +#define in_range(x, low, high) (((low) < (high)) && ((x) > (low) && (x) < (high))) || (((low) > (high)) && ((x) < (low) || (x) > (high))) + +// Check if value is in range A..B. If B < A, matches all outside B..A +#define in_range_wrap(x, low, high) (((low) < (high)) && ((x) > (low) && (x) < (high))) || (((low) > (high)) && ((x) > (low) || (x) < (high))) + +// === general bit manipulation with register === +#define sbi(reg, bit) do { (reg) |= (1 << (uint8_t)(bit)); } while(0) +#define cbi(reg, bit) do { (reg) &= ~(1 << (uint8_t)(bit)); } while(0) + +#define read_bit(reg, bit) ((((uint8_t)(reg)) >> (uint8_t)(bit)) & 0x1) +#define get_bit(reg, bit) read_bit(reg, bit) + +#define write_bit(reg, bit, value) do { (reg) = ((reg) & ~(1 << (uint8_t)(bit))) | (((uint8_t)(value) & 0x1) << (uint8_t)(bit)); } while(0) +#define set_bit(reg, bit, value) write_bit(reg, bit, value) +#define toggle_bit(reg, bit) do { (reg) ^= (1 << (uint8_t)(bit)); } while(0) + +// general pin manipulation - with pointer to register +#define sbi_p(reg_p, bit) do { (*(reg_p)) |= (1 << (uint8_t)(bit)); } while(0) +#define cbi_p(reg_p, bit) do { (*(reg_p)) &= ~(1 << (uint8_t)(bit)); } while(0) + +#define read_bit_p(reg_p, bit) ((*(reg_p) >> (uint8_t)(bit)) & 0x1) +#define get_bit_p(reg_p, bit) read_bit_p(reg_p, bit) + +#define write_bit_p(reg_p, bit, value) do { *(reg_p) = (*(reg_p) & ~(1 << ((uint8_t)(bit) & 0x1))) | (((uint8_t)(value) & 0x1) << (uint8_t)(bit)); } while(0) +#define set_bit_p(reg, bit, value) write_bit_p(reg_p, bit, value) +#define toggle_bit_p(reg_p, bit) do { *(reg_p) ^= (1 << (uint8_t)(bit)); } while(0) + diff --git a/lib/colors.h b/archive/141222_gamepad-rgb-test/lib/colors.h similarity index 100% rename from lib/colors.h rename to archive/141222_gamepad-rgb-test/lib/colors.h diff --git a/archive/141222_gamepad-rgb-test/lib/debounce.h b/archive/141222_gamepad-rgb-test/lib/debounce.h new file mode 100644 index 0000000..eaf233c --- /dev/null +++ b/archive/141222_gamepad-rgb-test/lib/debounce.h @@ -0,0 +1,104 @@ +#pragma once + +/** + An implementation of button debouncer. + + First, the system must be initialized - even before including: + + #define DEBO_CHANNELS 2 + #define DEBO_TICKS 5 + + #inclue "lib/debounce.h" + + A pin is registered like this: + + #define BTN1 B,0 + #define BTN2 B,1 + + debo_add(BTN0); // The function returns number assigned to the pin (0, 1, ...) + debo_add_rev(BTN1); // active low + debo_register(&PINB, PB2, 0); // direct access - register, pin & invert + + Then periodically call the tick function (perhaps in a timer interrupt): + + debo_tick(); + + To check if input is active, use + + debo_get_pin(0); // state of input registered as #0 + debo_get_pin(1); // state of input registered as #1 +*/ + +#include +#include + +#include "calc.h" +#include "pins.h" + + +// Number of pins to debounce +#ifndef DEBO_CHANNELS +# error "DEBO_CHANNELS not defined!" +#endif + +#ifndef DEBO_TICKS +# warning "DEBO_TICKS not defined, defaulting to 5!" +# define DEBO_TICKS 5 +#endif + + +/* Internal deboucer entry */ +typedef struct { + PORT_P reg; + uint8_t bit; + uint8_t count; +} debo_slot_t; + +/** Debounce data array */ +debo_slot_t debo_slots[DEBO_CHANNELS]; +uint8_t debo_next_slot = 0; + +/** Define a debounced pin (must be IO!) */ + +#define debo_add_rev(io) debo_register(&io2pin(io_pack(io)), io2n(io_pack(io)), 1) +#define debo_add(io) debo_register(&io2pin(io_pack(io)), io2n(io_pack(io)), 0) + +uint8_t debo_register(PORT_P reg, uint8_t bit, bool invert) +{ + debo_slots[debo_next_slot] = (debo_slot_t){ + .reg = reg, + .bit = bit | ((invert & 1) << 7) | (get_bit_p(reg, bit) << 6), // bit 7 = invert, bit 6 = state + .count = 0, + }; + + return debo_next_slot++; +} + + +/** Check debounced pins, should be called periodically. */ +void debo_tick() +{ + for (uint8_t i = 0; i < debo_next_slot; i++) { + // current pin value (right 3 bits, xored with inverse bit) + bool value = get_bit_p(debo_slots[i].reg, debo_slots[i].bit & 0x7); + + if (value != get_bit(debo_slots[i].bit, 6)) { + + // different pin state than last recorded state + if (debo_slots[i].count < DEBO_TICKS) { + debo_slots[i].count++; + } else { + // overflown -> latch value + set_bit(debo_slots[i].bit, 6, value); // set state bit + debo_slots[i].count = 0; + } + } else { + debo_slots[i].count = 0; // reset the counter + } + } +} + + +/** Get a value of debounced pin */ +#define debo_get_pin(i) (get_bit(debo_slots[i].bit, 6) ^ get_bit(debo_slots[i].bit, 7)) +//(get_bit(debo_slots[i].bit, 6) ^ get_bit(debo_slots[i].bit, 7)) diff --git a/lib/meta.h b/archive/141222_gamepad-rgb-test/lib/meta.h similarity index 100% rename from lib/meta.h rename to archive/141222_gamepad-rgb-test/lib/meta.h diff --git a/lib/nsdelay.h b/archive/141222_gamepad-rgb-test/lib/nsdelay.h similarity index 100% rename from lib/nsdelay.h rename to archive/141222_gamepad-rgb-test/lib/nsdelay.h diff --git a/archive/141222_gamepad-rgb-test/lib/pins.h b/archive/141222_gamepad-rgb-test/lib/pins.h new file mode 100644 index 0000000..93960b4 --- /dev/null +++ b/archive/141222_gamepad-rgb-test/lib/pins.h @@ -0,0 +1,107 @@ +#pragma once + +/** + This file provides macros for pin manipulation. + + You can define your application pins like so: + + // Led at PORTB, pin 1 + #define LED B,1 + + // Switch at PORTD, pin 7 + #define SW1 D,7 + + Now you can use macros from this file to wirh with the pins, eg: + + as_output(LED); + as_input(SW1); + pullup_on(SW1); + + toggle_pin(LED); + while (pin_is_low(SW1)); + + - The macros io2XXX() can be used to get literal name of register associated with the pin. + - io2n() provides pin number. + - The XXX_aux() macros are internal and should not be used elsewhere. + - The io_pack() macro is used to pass pin (io) to other macro without expanding it. +*/ + +#include +#include "calc.h" + + +// Get particular register associated with the name X (eg. D -> PORTD) +#define reg_ddr(X) DDR ## X +#define reg_port(X) PORT ## X +#define reg_pin(X) PIN ## X + +#define io2ddr_aux(reg, bit) reg_ddr(reg) +#define io2ddr(io) io2ddr_aux(io) +#define io2port_aux(reg, bit) reg_port(reg) +#define io2port(io) io2port_aux(io) +#define io2pin_aux(reg, bit) reg_pin(reg) +#define io2pin(io) io2pin_aux(io) +#define io2n_aux(reg, bit) bit +#define io2n(io) io2n_aux(io) + +#define io_pack(port, bit) port, bit + + +// pointer to port +typedef volatile uint8_t* PORT_P; +// number of bit in port +typedef uint8_t BIT_N; + + +// === pin manipulation === +#define set_pin_aux(port, bit) sbi(reg_port(port), (bit)) +#define clear_pin_aux(port, bit) cbi(reg_port(port), (bit)) +#define read_pin_aux(port, bit) get_bit(reg_pin(port), (bit)) +#define write_pin_aux(port, bit, value) set_bit(reg_port(port), (bit), (value)) +#define toggle_pin_aux(port, bit) sbi(reg_pin(port), (bit)) + + +#define pin_up(io) set_pin_aux(io) +#define pin_high(io) set_pin_aux(io) + +#define pin_down(io) clear_pin_aux(io) +#define pin_low(io) clear_pin_aux(io) + +#define get_pin(io) read_pin_aux(io) +#define read_pin(io) read_pin_aux(io) + +#define pin_is_low(io) !read_pin_aux(io) +#define pin_is_high(io) read_pin_aux(io) + +#define set_pin(io, value) write_pin_aux(io, (value)) +#define write_pin(io, value) write_pin_aux(io, (value)) +#define toggle_pin(io) toggle_pin_aux(io) + + + +// setting pin direction +#define as_input_aux(port, bit) cbi(reg_ddr(port), (bit)) +#define as_output_aux(port, bit) sbi(reg_ddr(port), (bit)) +#define set_dir_aux(port, bit, dir) write_bit(reg_ddr(port), (bit), (dir)) + + +#define as_input(io) as_input_aux(io) +#define as_input_pu(io) do { as_input_aux(io); pullup_enable_aux(io); } while(0) + +#define as_output(io) as_output_aux(io) +#define set_dir(io, dir) set_dir_aux(io, (dir)) + + +// setting pullup +#define pullup_enable_aux(port, bit) sbi(reg_port(port), (bit)) +#define pullup_disable_aux(port, bit) cbi(reg_port(port), (bit)) +#define set_pullup_aux(port, bit, on) write_bit(reg_port(port), (bit), (on)) + + +#define pullup_enable(io) pullup_enable_aux(io) +#define pullup_on(io) pullup_enable_aux(io) + +#define pullup_disable(io) pullup_disable_aux(io) +#define pullup_off(io) pullup_disable_aux(io) + +#define set_pullup(io, on) set_pullup_aux(io, on) diff --git a/archive/141222_gamepad-rgb-test/lib/ws2812.h b/archive/141222_gamepad-rgb-test/lib/ws2812.h new file mode 100644 index 0000000..815d250 --- /dev/null +++ b/archive/141222_gamepad-rgb-test/lib/ws2812.h @@ -0,0 +1,77 @@ +#pragma once + +/** + Utils for driving a WS2812 (WS2812B) RGB LED strips. + + It's implemented as macros to avoid overhead when passing values, and to + enable driving multiple strips at once. There is over 1us of free time between + the colors, which can be used for some processing or color computation. + + To avoid bloating your code, try to reduce the nuýmber of invocations - + compute color and then send it. +*/ + +#include + +#include "pins.h" +#include "nsdelay.h" +#include "colors.h" + +/* Driver code for WS2812B */ + +// --- timing constraints (NS) --- + +#ifndef WS_T_1H +# define WS_T_1H 700 +#endif + +#ifndef WS_T_1L +# define WS_T_1L 150 +#endif + +#ifndef WS_T_0H +# define WS_T_0H 150 +#endif + +#ifndef WS_T_0L +# define WS_T_0L 700 +#endif + +#ifndef WS_T_LATCH +# define WS_T_LATCH 7000 +#endif + + +/** Wait long enough for the colors to show */ +#define ws_show() do { delay_ns_c(WS_T_LATCH, 0); } while(0) + + +/** Send one byte to the RGB strip */ +#define ws_send_byte(io, bb) do { \ + for (volatile int8_t __wsba_i = 7; __wsba_i >= 0; --__wsba_i) { \ + if ((bb) & (1 << __wsba_i)) { \ + pin_high(io_pack(io)); delay_ns_c(WS_T_1H, -2); \ + pin_low(io_pack(io)); delay_ns_c(WS_T_1L, -10); \ + } else { \ + pin_high(io_pack(io)); delay_ns_c(WS_T_0H, -2); \ + pin_low(io_pack(io)); delay_ns_c(WS_T_0L, -10); \ + } \ + } \ +} while(0) + + +/** Send R,G,B color to the strip */ +#define ws_send_rgb(io, r, g, b) do { \ + ws_send_byte(io_pack(io), g); \ + ws_send_byte(io_pack(io), r); \ + ws_send_byte(io_pack(io), b); \ +} while(0) + +/** Send a RGB struct */ +#define ws_send_xrgb(io, xrgb) ws_send_rgb(io_pack(io), (xrgb).r, (xrgb).g, (xrgb).b) + +/** Send color hex */ +#define ws_send_rgb24(io, rgb) ws_send_rgb(io_pack(io), rgb24_r(rgb), rgb24_g(rgb), rgb24_b(rgb)) +#define ws_send_rgb15(io, rgb) ws_send_rgb(io_pack(io), rgb15_r(rgb), rgb15_g(rgb), rgb15_b(rgb)) +#define ws_send_rgb12(io, rgb) ws_send_rgb(io_pack(io), rgb12_r(rgb), rgb12_g(rgb), rgb12_b(rgb)) +#define ws_send_rgb6(io, rgb) ws_send_rgb(io_pack(io), rgb6_r(rgb), rgb6_g(rgb), rgb6_b(rgb)) diff --git a/archive/141222_gamepad-rgb-test/main.c b/archive/141222_gamepad-rgb-test/main.c new file mode 100644 index 0000000..cdca085 --- /dev/null +++ b/archive/141222_gamepad-rgb-test/main.c @@ -0,0 +1,145 @@ +#include +#include +#include +// #include +#include + +#include "lib/meta.h" +#include "lib/arduino_pins.h" +#include "lib/calc.h" +#include "lib/colors.h" +#include "lib/ws2812.h" + +#define DEBO_CHANNELS 11 +#define DEBO_TICKS 1 // 0.01s + +#include "lib/debounce.h" + +#define WS1 D10 + +#define BTN_LEFT D2 +#define BTN_RIGHT D3 +#define BTN_UP D4 +#define BTN_DOWN D5 +#define BTN_A D6 +#define BTN_B D7 +#define BTN_AA D8 +#define BTN_BB D9 +#define BTN_SLOW D14 +#define BTN_START D15 +#define BTN_SELECT D16 + +void render(); + +void SECTION(".init8") init_io() +{ + // led strip data + as_output(WS1); + + // gamepad buttons + as_input_pu(BTN_LEFT); + as_input_pu(BTN_RIGHT); + as_input_pu(BTN_UP); + as_input_pu(BTN_DOWN); + + as_input_pu(BTN_A); + as_input_pu(BTN_B); + as_input_pu(BTN_AA); + as_input_pu(BTN_BB); + + as_input_pu(BTN_SLOW); + as_input_pu(BTN_START); + as_input_pu(BTN_SELECT); + + // set up debouncers + #define BTN_LEFT_D 0 + debo_add_rev(BTN_LEFT); + + #define BTN_RIGHT_D 1 + debo_add_rev(BTN_RIGHT); + + #define BTN_UP_D 2 + debo_add_rev(BTN_UP); + + #define BTN_DOWN_D 3 + debo_add_rev(BTN_DOWN); + + #define BTN_A_D 4 + debo_add_rev(BTN_A); + + #define BTN_B_D 5 + debo_add_rev(BTN_B); + + #define BTN_AA_D 6 + debo_add_rev(BTN_AA); + + #define BTN_BB_D 7 + debo_add_rev(BTN_BB); + + #define BTN_SLOW_D 8 + debo_add_rev(BTN_SLOW); + + #define BTN_START_D 9 + debo_add_rev(BTN_START); + + #define BTN_SELECT_D 10 + debo_add_rev(BTN_SELECT); + + + // setup timer 10 ms + TCCR0A = _BV(WGM01); // CTC + TCCR0B = _BV(CS02) | _BV(CS00); // prescaler 512 + OCR0A = 156; // interrupt every 10 ms + sbi(TIMSK0, OCIE0A); + sei(); +} + +/** timer 0 interrupt vector */ +ISR(TIMER0_COMPA_vect) +{ + debo_tick(); // poll debouncer + render(); +} + + +void render() +{ + const rgb24_t PINK = 0x970078; + const rgb24_t BLUE = 0x005397; + const rgb24_t RED = 0xFF0000; + const rgb24_t YELLOW = 0xFFFF00; + const rgb24_t BLACK = 0x000000; + + static rgb24_t table[12]; + + table[0] = debo_get_pin(BTN_LEFT_D) ? PINK : BLACK; + table[1] = debo_get_pin(BTN_RIGHT_D) ? PINK : BLACK; + table[2] = debo_get_pin(BTN_UP_D) ? PINK : BLACK; + table[3] = debo_get_pin(BTN_DOWN_D) ? PINK : BLACK; + table[4] = debo_get_pin(BTN_A_D) ? BLUE : BLACK; + table[5] = debo_get_pin(BTN_B_D) ? BLUE : BLACK; + table[6] = debo_get_pin(BTN_AA_D) ? BLUE : BLACK; + table[7] = debo_get_pin(BTN_BB_D) ? BLUE : BLACK; + table[8] = debo_get_pin(BTN_SELECT_D) ? RED : BLACK; + table[9] = debo_get_pin(BTN_START_D) ? RED : BLACK; + table[10] = debo_get_pin(BTN_SLOW_D) ? RED : BLACK; + table[11] = YELLOW; + + rgb24_t c; + for (uint8_t i=0; i<30; i++) { + + if (i < 12) + c = table[i]; + else + c = BLACK; + + ws_send_rgb24(WS1, c); + } +} + + +void main() +{ + // render(); + while(1) {} +} diff --git a/rgb-led-strip/arduino-ws-anim-rainbow/Makefile b/archive/141222_rgb-strip-anim-rainbow/Makefile similarity index 100% rename from rgb-led-strip/arduino-ws-anim-rainbow/Makefile rename to archive/141222_rgb-strip-anim-rainbow/Makefile diff --git a/lib/arduino_pins.h b/archive/141222_rgb-strip-anim-rainbow/lib/arduino_pins.h similarity index 100% rename from lib/arduino_pins.h rename to archive/141222_rgb-strip-anim-rainbow/lib/arduino_pins.h diff --git a/lib/calc.h b/archive/141222_rgb-strip-anim-rainbow/lib/calc.h similarity index 100% rename from lib/calc.h rename to archive/141222_rgb-strip-anim-rainbow/lib/calc.h diff --git a/archive/141222_rgb-strip-anim-rainbow/lib/colors.h b/archive/141222_rgb-strip-anim-rainbow/lib/colors.h new file mode 100644 index 0000000..454923b --- /dev/null +++ b/archive/141222_rgb-strip-anim-rainbow/lib/colors.h @@ -0,0 +1,57 @@ +#pragma once + +/* + Some useful utilities for RGB color manipulation +*/ + +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; +} xrgb_t; + +typedef uint32_t rgb24_t; +typedef uint16_t rgb16_t; +typedef uint16_t rgb12_t; +typedef uint8_t rgb6_t; + + +#define xrgb(rr, gg, bb) { .r = ((uint8_t)(rr)), .g = ((uint8_t)(gg)), .b = ((uint8_t)(bb)) } +#define xrgb_r(c) ((uint8_t)(c.r)) +#define xrgb_g(c) ((uint8_t)(c.g)) +#define xrgb_b(c) ((uint8_t)(c.b)) +#define xrgb_rgb24(c) ((((rgb24_t)c.r) << 16) | (((rgb24_t)c.g) << 8) | (((rgb24_t)c.b))) +#define xrgb_rgb15(c) (((((rgb15_t)c.r) & 0xF8) << 7) | ((((rgb15_t)c.g) & 0xF8) << 2) | ((((rgb15_t)c.b) & 0xF8) >> 3)) +#define xrgb_rgb12(c) (((((rgb12_t)c.r) & 0xF0) << 4) | ((((rgb12_t)c.g) & 0xF0)) | ((((rgb12_t)c.b) & 0xF0) >> 4)) +#define xrgb_rgb6(c) (((((rgb6_t)c.r) & 0xC0) >> 2) | ((((rgb6_t)c.g) & 0xC0) >> 4) | ((((rgb6_t)c.b) & 0xC0) >> 6)) + + +#define rgb24(r,g,b) ((rgb24_t) (((((rgb24_t)r) & 0xFF) << 16) | ((((rgb24_t)g) & 0xFF) << 8) | (((rgb24_t)b) & 0xFF))) +#define rgb24_r(c) ((((rgb24_t) (c)) >> 16) & 0xFF) +#define rgb24_g(c) ((((rgb24_t) (c)) >> 8) & 0xFF) +#define rgb24_b(c) ((((rgb24_t) (c)) >> 0) & 0xFF) +#define rgb24_xrgb(c) xrgb(rgb24_r(c), rgb24_g(c), rgb24_b(c)) + + +#define rgb15(r,g,b) ((rgb16_t) (((r & 0x1F) << 10) | ((g & 0x1F) << 5) | (b & 0x1F))) +#define rgb15_r(c) ((((rgb15_t) (c)) & 0x7C00) >> 7) +#define rgb15_g(c) ((((rgb15_t) (c)) & 0x3E0) >> 2) +#define rgb15_b(c) ((((rgb15_t) (c)) & 0x1F) << 3) +#define rgb15_xrgb(c) xrgb(rgb15_r(c), rgb15_g(c), rgb15_b(c)) +#define rgb15_rgb24(c) rgb24(rgb15_r(c), rgb15_g(c), rgb15_b(c)) + + +#define rgb12(r,g,b) ((rgb12_t) (((r & 0xF) << 8) | ((g & 0xF) << 4) | (b & 0xF))) +#define rgb12_r(c) ((((rgb12_t) (c)) & 0xF00) >> 4) +#define rgb12_g(c) (((rgb12_t) (c)) & 0xF0) +#define rgb12_b(c) (((r(rgb12_t) (c)gb) & 0x0F) << 4) +#define rgb12_xrgb(c) xrgb(rgb12_r(c), rgb12_g(c), rgb12_b(c)) +#define rgb12_rgb24(c) rgb24(rgb12_r(c), rgb12_g(c), rgb12_b(c)) + + +#define rgb6(r,g,b) ((rgb6_t) (((r & 3) << 4) | ((g & 3) << 2) | (b & 3))) +#define rgb6_r(c) ((((rgb6_t) (c)) & 0x30) << 2) +#define rgb6_g(c) ((((rgb6_t) (c)) & 0xC) << 4) +#define rgb6_b(c) ((((rgb6_t) (c)) & 0x3) << 6) +#define rgb6_xrgb(c) xrgb(rgb6_r(c), rgb6_g(c), rgb6_b(c)) +#define rgb6_rgb24(c) rgb24(rgb6_r(c), rgb6_g(c), rgb6_b(c)) diff --git a/archive/141222_rgb-strip-anim-rainbow/lib/meta.h b/archive/141222_rgb-strip-anim-rainbow/lib/meta.h new file mode 100644 index 0000000..ec16799 --- /dev/null +++ b/archive/141222_rgb-strip-anim-rainbow/lib/meta.h @@ -0,0 +1,6 @@ +#pragma once + +/** Weird constructs for the compiler */ + +// general macros +#define SECTION(pos) __attribute__((naked, used, section(pos))) diff --git a/archive/141222_rgb-strip-anim-rainbow/lib/nsdelay.h b/archive/141222_rgb-strip-anim-rainbow/lib/nsdelay.h new file mode 100644 index 0000000..0a1e843 --- /dev/null +++ b/archive/141222_rgb-strip-anim-rainbow/lib/nsdelay.h @@ -0,0 +1,18 @@ +#pragma once + +/** + Functions for precise delays (nanoseconds / cycles) +*/ + +#include +#include +#include + +/* Convert nanoseconds to cycle count */ +#define ns2cycles(ns) ( (ns) / (1000000000L / (signed long) F_CPU) ) + +/** Wait c cycles */ +#define delay_c(c) (((c) > 0) ? __builtin_avr_delay_cycles(c) : __builtin_avr_delay_cycles(0)) + +/** Wait n nanoseconds, plus c cycles */ +#define delay_ns_c(ns, c) delay_c(ns2cycles(ns) + (c)) diff --git a/lib/pins.h b/archive/141222_rgb-strip-anim-rainbow/lib/pins.h similarity index 100% rename from lib/pins.h rename to archive/141222_rgb-strip-anim-rainbow/lib/pins.h diff --git a/lib/ws2812.h b/archive/141222_rgb-strip-anim-rainbow/lib/ws2812.h similarity index 100% rename from lib/ws2812.h rename to archive/141222_rgb-strip-anim-rainbow/lib/ws2812.h diff --git a/rgb-led-strip/arduino-ws-anim-rainbow/main.c b/archive/141222_rgb-strip-anim-rainbow/main.c similarity index 100% rename from rgb-led-strip/arduino-ws-anim-rainbow/main.c rename to archive/141222_rgb-strip-anim-rainbow/main.c diff --git a/new-pins-test/Makefile b/devel/colorchase-anim/Makefile similarity index 83% rename from new-pins-test/Makefile rename to devel/colorchase-anim/Makefile index 9f4c5f1..82a8c47 100644 --- a/new-pins-test/Makefile +++ b/devel/colorchase-anim/Makefile @@ -1,10 +1,11 @@ -MCU = attiny13 +MCU = atmega328p -F_CPU = 9600000 +F_CPU = 16000000 -LFUSE = 0x72 -HFUSE = 0xFF +LFUSE = 0xFF +HFUSE = 0xDE +EFUSE = 0x05 MAIN = main.c @@ -25,9 +26,9 @@ EXTRA_SOURCE_FILES = ########## Set up once, then forget about it ########## ########## (Can override. See bottom of file.) ########## ##########------------------------------------------------------########## - -PROGRAMMER_TYPE = dragon_isp -PROGRAMMER_ARGS = +#19200 +PROGRAMMER_TYPE = arduino +PROGRAMMER_ARGS = -b 57600 -P /dev/ttyUSB0 ##########------------------------------------------------------########## @@ -47,19 +48,22 @@ AVRSIZE = avr-size AVRDUDE = sudo avrdude ## Compilation options, type man avr-gcc if you're curious. -CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -Os -I. -I$(EXTRA_SOURCE_DIR) +CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -I. -I$(EXTRA_SOURCE_DIR) CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS += -Wall -Wno-main -CFLAGS += -g2 -ggdb +CFLAGS += -Wall -Wno-main -Wno-strict-prototypes -Wno-comment +CFLAGS += -g2 -Wextra -pedantic -Wfatal-errors CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--relax -CFLAGS += -std=gnu99 + +CFLAGS_BUILD = $(CFLAGS) -Os + # CFLAGS += -lm ## CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf ## CFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf ## Lump target and extra source files together TARGET = $(strip $(basename $(MAIN))) -SRC = $(TARGET).c +SRC1 = $(TARGET).c +SRC = $(SRC1) EXTRA_SOURCE = $(addprefix $(EXTRA_SOURCE_DIR), $(EXTRA_SOURCE_FILES)) SRC += $(EXTRA_SOURCE) SRC += $(LOCAL_SOURCE) @@ -72,12 +76,16 @@ OBJ = $(SRC:.c=.o) ## Generic Makefile targets. (Only .hex file is necessary) all: $(TARGET).hex size +pre: $(TARGET).pre %.hex: %.elf $(OBJCOPY) -R .eeprom -O ihex $< $@ %.elf: $(SRC) - $(CC) $(CFLAGS) $(SRC) --output $@ + $(CC) $(CFLAGS_BUILD) $(SRC) --output $@ + +%.pre: $(SRC1) + $(CC) $(CFLAGS) -E $(SRC1) --output $@ %.eeprom: %.elf $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ @@ -95,6 +103,7 @@ debug: disassemble: $(TARGET).lst dis: disassemble +lst: disassemble eeprom: $(TARGET).eeprom @@ -130,6 +139,10 @@ terminal: $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt +flash_arduino: PROGRAMMER_TYPE = arduino +flash_arduino: PROGRAMMER_ARGS = +flash_arduino: flash + flash_dragon_isp: PROGRAMMER_TYPE = dragon_isp flash_dragon_isp: PROGRAMMER_ARGS = flash_dragon_isp: flash @@ -140,7 +153,7 @@ flash_dragon_isp: flash ##########------------------------------------------------------########## ## Generic -FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m +FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m fuses: $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \ @@ -149,5 +162,5 @@ show_fuses: $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv ## Called with no extra definitions, sets to defaults -set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m +set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -U efuse:w:$(EFUSE):m set_default_fuses: fuses diff --git a/devel/colorchase-anim/lib b/devel/colorchase-anim/lib new file mode 120000 index 0000000..dc598c5 --- /dev/null +++ b/devel/colorchase-anim/lib @@ -0,0 +1 @@ +../lib \ No newline at end of file diff --git a/devel/colorchase-anim/main.c b/devel/colorchase-anim/main.c new file mode 100644 index 0000000..cdca085 --- /dev/null +++ b/devel/colorchase-anim/main.c @@ -0,0 +1,145 @@ +#include +#include +#include +// #include +#include + +#include "lib/meta.h" +#include "lib/arduino_pins.h" +#include "lib/calc.h" +#include "lib/colors.h" +#include "lib/ws2812.h" + +#define DEBO_CHANNELS 11 +#define DEBO_TICKS 1 // 0.01s + +#include "lib/debounce.h" + +#define WS1 D10 + +#define BTN_LEFT D2 +#define BTN_RIGHT D3 +#define BTN_UP D4 +#define BTN_DOWN D5 +#define BTN_A D6 +#define BTN_B D7 +#define BTN_AA D8 +#define BTN_BB D9 +#define BTN_SLOW D14 +#define BTN_START D15 +#define BTN_SELECT D16 + +void render(); + +void SECTION(".init8") init_io() +{ + // led strip data + as_output(WS1); + + // gamepad buttons + as_input_pu(BTN_LEFT); + as_input_pu(BTN_RIGHT); + as_input_pu(BTN_UP); + as_input_pu(BTN_DOWN); + + as_input_pu(BTN_A); + as_input_pu(BTN_B); + as_input_pu(BTN_AA); + as_input_pu(BTN_BB); + + as_input_pu(BTN_SLOW); + as_input_pu(BTN_START); + as_input_pu(BTN_SELECT); + + // set up debouncers + #define BTN_LEFT_D 0 + debo_add_rev(BTN_LEFT); + + #define BTN_RIGHT_D 1 + debo_add_rev(BTN_RIGHT); + + #define BTN_UP_D 2 + debo_add_rev(BTN_UP); + + #define BTN_DOWN_D 3 + debo_add_rev(BTN_DOWN); + + #define BTN_A_D 4 + debo_add_rev(BTN_A); + + #define BTN_B_D 5 + debo_add_rev(BTN_B); + + #define BTN_AA_D 6 + debo_add_rev(BTN_AA); + + #define BTN_BB_D 7 + debo_add_rev(BTN_BB); + + #define BTN_SLOW_D 8 + debo_add_rev(BTN_SLOW); + + #define BTN_START_D 9 + debo_add_rev(BTN_START); + + #define BTN_SELECT_D 10 + debo_add_rev(BTN_SELECT); + + + // setup timer 10 ms + TCCR0A = _BV(WGM01); // CTC + TCCR0B = _BV(CS02) | _BV(CS00); // prescaler 512 + OCR0A = 156; // interrupt every 10 ms + sbi(TIMSK0, OCIE0A); + sei(); +} + +/** timer 0 interrupt vector */ +ISR(TIMER0_COMPA_vect) +{ + debo_tick(); // poll debouncer + render(); +} + + +void render() +{ + const rgb24_t PINK = 0x970078; + const rgb24_t BLUE = 0x005397; + const rgb24_t RED = 0xFF0000; + const rgb24_t YELLOW = 0xFFFF00; + const rgb24_t BLACK = 0x000000; + + static rgb24_t table[12]; + + table[0] = debo_get_pin(BTN_LEFT_D) ? PINK : BLACK; + table[1] = debo_get_pin(BTN_RIGHT_D) ? PINK : BLACK; + table[2] = debo_get_pin(BTN_UP_D) ? PINK : BLACK; + table[3] = debo_get_pin(BTN_DOWN_D) ? PINK : BLACK; + table[4] = debo_get_pin(BTN_A_D) ? BLUE : BLACK; + table[5] = debo_get_pin(BTN_B_D) ? BLUE : BLACK; + table[6] = debo_get_pin(BTN_AA_D) ? BLUE : BLACK; + table[7] = debo_get_pin(BTN_BB_D) ? BLUE : BLACK; + table[8] = debo_get_pin(BTN_SELECT_D) ? RED : BLACK; + table[9] = debo_get_pin(BTN_START_D) ? RED : BLACK; + table[10] = debo_get_pin(BTN_SLOW_D) ? RED : BLACK; + table[11] = YELLOW; + + rgb24_t c; + for (uint8_t i=0; i<30; i++) { + + if (i < 12) + c = table[i]; + else + c = BLACK; + + ws_send_rgb24(WS1, c); + } +} + + +void main() +{ + // render(); + while(1) {} +} diff --git a/devel/lib/README.md b/devel/lib/README.md new file mode 100644 index 0000000..ae3661a --- /dev/null +++ b/devel/lib/README.md @@ -0,0 +1,6 @@ +MightyPorsk's AVR utils library +=============================== + +This is my ever-evolving library. When I'm done with a project, I copy the current library to the project, so it doesn't break when I do further improvements. + +Each library file contains a large comment block explaining it's function. diff --git a/devel/lib/arduino_pins.h b/devel/lib/arduino_pins.h new file mode 100644 index 0000000..ca4f4c6 --- /dev/null +++ b/devel/lib/arduino_pins.h @@ -0,0 +1,42 @@ +#pragma once + +/** + Pin definitions for Arduino (Pro Mini with ATmega328P) +*/ + +#include "pins.h" + +#define D0 D,0 +#define D1 D,1 +#define D2 D,2 +#define D3 D,3 +#define D4 D,4 +#define D5 D,5 +#define D6 D,6 +#define D7 D,7 +#define D8 B,0 +#define D9 B,1 +#define D10 B,2 + +// MOSI MISO SCK - not good for input +#define D11 B,3 +#define D12 B,4 +#define D13 B,5 + +#define D14 C,0 +#define D15 C,1 +#define D16 C,2 +#define D17 C,3 +#define D18 C,4 +#define D19 C,5 +#define D20 C,6 +#define D21 C,7 + +#define A0 C,0 +#define A1 C,1 +#define A2 C,2 +#define A3 C,3 +#define A4 C,4 +#define A5 C,5 +#define A6 C,6 +#define A7 C,7 diff --git a/devel/lib/calc.h b/devel/lib/calc.h new file mode 100644 index 0000000..d2602bb --- /dev/null +++ b/devel/lib/calc.h @@ -0,0 +1,40 @@ +#pragma once + +/** + General purpose calculation and bit manipulation utilities. +*/ + +// if max, go to zero. Else increment. +#define inc_wrap(var, max) do { if ((var) >= (max)) { (var)=0; } else { (var)++; } } while(0) + +// If zero, go to max. Else decrement, +#define dec_wrap(var, max) do { if ((var) > 0) { (var)--; } else { (var)=(max); } } while(0) + +// Check if value is in range A..B or B..A +#define in_range(x, low, high) (((low) < (high)) && ((x) > (low) && (x) < (high))) || (((low) > (high)) && ((x) < (low) || (x) > (high))) + +// Check if value is in range A..B. If B < A, matches all outside B..A +#define in_range_wrap(x, low, high) (((low) < (high)) && ((x) > (low) && (x) < (high))) || (((low) > (high)) && ((x) > (low) || (x) < (high))) + +// === general bit manipulation with register === +#define sbi(reg, bit) do { (reg) |= (1 << (uint8_t)(bit)); } while(0) +#define cbi(reg, bit) do { (reg) &= ~(1 << (uint8_t)(bit)); } while(0) + +#define read_bit(reg, bit) ((((uint8_t)(reg)) >> (uint8_t)(bit)) & 0x1) +#define get_bit(reg, bit) read_bit(reg, bit) + +#define write_bit(reg, bit, value) do { (reg) = ((reg) & ~(1 << (uint8_t)(bit))) | (((uint8_t)(value) & 0x1) << (uint8_t)(bit)); } while(0) +#define set_bit(reg, bit, value) write_bit(reg, bit, value) +#define toggle_bit(reg, bit) do { (reg) ^= (1 << (uint8_t)(bit)); } while(0) + +// general pin manipulation - with pointer to register +#define sbi_p(reg_p, bit) do { (*(reg_p)) |= (1 << (uint8_t)(bit)); } while(0) +#define cbi_p(reg_p, bit) do { (*(reg_p)) &= ~(1 << (uint8_t)(bit)); } while(0) + +#define read_bit_p(reg_p, bit) ((*(reg_p) >> (uint8_t)(bit)) & 0x1) +#define get_bit_p(reg_p, bit) read_bit_p(reg_p, bit) + +#define write_bit_p(reg_p, bit, value) do { *(reg_p) = (*(reg_p) & ~(1 << ((uint8_t)(bit) & 0x1))) | (((uint8_t)(value) & 0x1) << (uint8_t)(bit)); } while(0) +#define set_bit_p(reg, bit, value) write_bit_p(reg_p, bit, value) +#define toggle_bit_p(reg_p, bit) do { *(reg_p) ^= (1 << (uint8_t)(bit)); } while(0) + diff --git a/devel/lib/colors.h b/devel/lib/colors.h new file mode 100644 index 0000000..454923b --- /dev/null +++ b/devel/lib/colors.h @@ -0,0 +1,57 @@ +#pragma once + +/* + Some useful utilities for RGB color manipulation +*/ + +typedef struct { + uint8_t r; + uint8_t g; + uint8_t b; +} xrgb_t; + +typedef uint32_t rgb24_t; +typedef uint16_t rgb16_t; +typedef uint16_t rgb12_t; +typedef uint8_t rgb6_t; + + +#define xrgb(rr, gg, bb) { .r = ((uint8_t)(rr)), .g = ((uint8_t)(gg)), .b = ((uint8_t)(bb)) } +#define xrgb_r(c) ((uint8_t)(c.r)) +#define xrgb_g(c) ((uint8_t)(c.g)) +#define xrgb_b(c) ((uint8_t)(c.b)) +#define xrgb_rgb24(c) ((((rgb24_t)c.r) << 16) | (((rgb24_t)c.g) << 8) | (((rgb24_t)c.b))) +#define xrgb_rgb15(c) (((((rgb15_t)c.r) & 0xF8) << 7) | ((((rgb15_t)c.g) & 0xF8) << 2) | ((((rgb15_t)c.b) & 0xF8) >> 3)) +#define xrgb_rgb12(c) (((((rgb12_t)c.r) & 0xF0) << 4) | ((((rgb12_t)c.g) & 0xF0)) | ((((rgb12_t)c.b) & 0xF0) >> 4)) +#define xrgb_rgb6(c) (((((rgb6_t)c.r) & 0xC0) >> 2) | ((((rgb6_t)c.g) & 0xC0) >> 4) | ((((rgb6_t)c.b) & 0xC0) >> 6)) + + +#define rgb24(r,g,b) ((rgb24_t) (((((rgb24_t)r) & 0xFF) << 16) | ((((rgb24_t)g) & 0xFF) << 8) | (((rgb24_t)b) & 0xFF))) +#define rgb24_r(c) ((((rgb24_t) (c)) >> 16) & 0xFF) +#define rgb24_g(c) ((((rgb24_t) (c)) >> 8) & 0xFF) +#define rgb24_b(c) ((((rgb24_t) (c)) >> 0) & 0xFF) +#define rgb24_xrgb(c) xrgb(rgb24_r(c), rgb24_g(c), rgb24_b(c)) + + +#define rgb15(r,g,b) ((rgb16_t) (((r & 0x1F) << 10) | ((g & 0x1F) << 5) | (b & 0x1F))) +#define rgb15_r(c) ((((rgb15_t) (c)) & 0x7C00) >> 7) +#define rgb15_g(c) ((((rgb15_t) (c)) & 0x3E0) >> 2) +#define rgb15_b(c) ((((rgb15_t) (c)) & 0x1F) << 3) +#define rgb15_xrgb(c) xrgb(rgb15_r(c), rgb15_g(c), rgb15_b(c)) +#define rgb15_rgb24(c) rgb24(rgb15_r(c), rgb15_g(c), rgb15_b(c)) + + +#define rgb12(r,g,b) ((rgb12_t) (((r & 0xF) << 8) | ((g & 0xF) << 4) | (b & 0xF))) +#define rgb12_r(c) ((((rgb12_t) (c)) & 0xF00) >> 4) +#define rgb12_g(c) (((rgb12_t) (c)) & 0xF0) +#define rgb12_b(c) (((r(rgb12_t) (c)gb) & 0x0F) << 4) +#define rgb12_xrgb(c) xrgb(rgb12_r(c), rgb12_g(c), rgb12_b(c)) +#define rgb12_rgb24(c) rgb24(rgb12_r(c), rgb12_g(c), rgb12_b(c)) + + +#define rgb6(r,g,b) ((rgb6_t) (((r & 3) << 4) | ((g & 3) << 2) | (b & 3))) +#define rgb6_r(c) ((((rgb6_t) (c)) & 0x30) << 2) +#define rgb6_g(c) ((((rgb6_t) (c)) & 0xC) << 4) +#define rgb6_b(c) ((((rgb6_t) (c)) & 0x3) << 6) +#define rgb6_xrgb(c) xrgb(rgb6_r(c), rgb6_g(c), rgb6_b(c)) +#define rgb6_rgb24(c) rgb24(rgb6_r(c), rgb6_g(c), rgb6_b(c)) diff --git a/devel/lib/debounce.h b/devel/lib/debounce.h new file mode 100644 index 0000000..eaf233c --- /dev/null +++ b/devel/lib/debounce.h @@ -0,0 +1,104 @@ +#pragma once + +/** + An implementation of button debouncer. + + First, the system must be initialized - even before including: + + #define DEBO_CHANNELS 2 + #define DEBO_TICKS 5 + + #inclue "lib/debounce.h" + + A pin is registered like this: + + #define BTN1 B,0 + #define BTN2 B,1 + + debo_add(BTN0); // The function returns number assigned to the pin (0, 1, ...) + debo_add_rev(BTN1); // active low + debo_register(&PINB, PB2, 0); // direct access - register, pin & invert + + Then periodically call the tick function (perhaps in a timer interrupt): + + debo_tick(); + + To check if input is active, use + + debo_get_pin(0); // state of input registered as #0 + debo_get_pin(1); // state of input registered as #1 +*/ + +#include +#include + +#include "calc.h" +#include "pins.h" + + +// Number of pins to debounce +#ifndef DEBO_CHANNELS +# error "DEBO_CHANNELS not defined!" +#endif + +#ifndef DEBO_TICKS +# warning "DEBO_TICKS not defined, defaulting to 5!" +# define DEBO_TICKS 5 +#endif + + +/* Internal deboucer entry */ +typedef struct { + PORT_P reg; + uint8_t bit; + uint8_t count; +} debo_slot_t; + +/** Debounce data array */ +debo_slot_t debo_slots[DEBO_CHANNELS]; +uint8_t debo_next_slot = 0; + +/** Define a debounced pin (must be IO!) */ + +#define debo_add_rev(io) debo_register(&io2pin(io_pack(io)), io2n(io_pack(io)), 1) +#define debo_add(io) debo_register(&io2pin(io_pack(io)), io2n(io_pack(io)), 0) + +uint8_t debo_register(PORT_P reg, uint8_t bit, bool invert) +{ + debo_slots[debo_next_slot] = (debo_slot_t){ + .reg = reg, + .bit = bit | ((invert & 1) << 7) | (get_bit_p(reg, bit) << 6), // bit 7 = invert, bit 6 = state + .count = 0, + }; + + return debo_next_slot++; +} + + +/** Check debounced pins, should be called periodically. */ +void debo_tick() +{ + for (uint8_t i = 0; i < debo_next_slot; i++) { + // current pin value (right 3 bits, xored with inverse bit) + bool value = get_bit_p(debo_slots[i].reg, debo_slots[i].bit & 0x7); + + if (value != get_bit(debo_slots[i].bit, 6)) { + + // different pin state than last recorded state + if (debo_slots[i].count < DEBO_TICKS) { + debo_slots[i].count++; + } else { + // overflown -> latch value + set_bit(debo_slots[i].bit, 6, value); // set state bit + debo_slots[i].count = 0; + } + } else { + debo_slots[i].count = 0; // reset the counter + } + } +} + + +/** Get a value of debounced pin */ +#define debo_get_pin(i) (get_bit(debo_slots[i].bit, 6) ^ get_bit(debo_slots[i].bit, 7)) +//(get_bit(debo_slots[i].bit, 6) ^ get_bit(debo_slots[i].bit, 7)) diff --git a/devel/lib/meta.h b/devel/lib/meta.h new file mode 100644 index 0000000..ec16799 --- /dev/null +++ b/devel/lib/meta.h @@ -0,0 +1,6 @@ +#pragma once + +/** Weird constructs for the compiler */ + +// general macros +#define SECTION(pos) __attribute__((naked, used, section(pos))) diff --git a/devel/lib/nsdelay.h b/devel/lib/nsdelay.h new file mode 100644 index 0000000..0a1e843 --- /dev/null +++ b/devel/lib/nsdelay.h @@ -0,0 +1,18 @@ +#pragma once + +/** + Functions for precise delays (nanoseconds / cycles) +*/ + +#include +#include +#include + +/* Convert nanoseconds to cycle count */ +#define ns2cycles(ns) ( (ns) / (1000000000L / (signed long) F_CPU) ) + +/** Wait c cycles */ +#define delay_c(c) (((c) > 0) ? __builtin_avr_delay_cycles(c) : __builtin_avr_delay_cycles(0)) + +/** Wait n nanoseconds, plus c cycles */ +#define delay_ns_c(ns, c) delay_c(ns2cycles(ns) + (c)) diff --git a/devel/lib/pins.h b/devel/lib/pins.h new file mode 100644 index 0000000..93960b4 --- /dev/null +++ b/devel/lib/pins.h @@ -0,0 +1,107 @@ +#pragma once + +/** + This file provides macros for pin manipulation. + + You can define your application pins like so: + + // Led at PORTB, pin 1 + #define LED B,1 + + // Switch at PORTD, pin 7 + #define SW1 D,7 + + Now you can use macros from this file to wirh with the pins, eg: + + as_output(LED); + as_input(SW1); + pullup_on(SW1); + + toggle_pin(LED); + while (pin_is_low(SW1)); + + - The macros io2XXX() can be used to get literal name of register associated with the pin. + - io2n() provides pin number. + - The XXX_aux() macros are internal and should not be used elsewhere. + - The io_pack() macro is used to pass pin (io) to other macro without expanding it. +*/ + +#include +#include "calc.h" + + +// Get particular register associated with the name X (eg. D -> PORTD) +#define reg_ddr(X) DDR ## X +#define reg_port(X) PORT ## X +#define reg_pin(X) PIN ## X + +#define io2ddr_aux(reg, bit) reg_ddr(reg) +#define io2ddr(io) io2ddr_aux(io) +#define io2port_aux(reg, bit) reg_port(reg) +#define io2port(io) io2port_aux(io) +#define io2pin_aux(reg, bit) reg_pin(reg) +#define io2pin(io) io2pin_aux(io) +#define io2n_aux(reg, bit) bit +#define io2n(io) io2n_aux(io) + +#define io_pack(port, bit) port, bit + + +// pointer to port +typedef volatile uint8_t* PORT_P; +// number of bit in port +typedef uint8_t BIT_N; + + +// === pin manipulation === +#define set_pin_aux(port, bit) sbi(reg_port(port), (bit)) +#define clear_pin_aux(port, bit) cbi(reg_port(port), (bit)) +#define read_pin_aux(port, bit) get_bit(reg_pin(port), (bit)) +#define write_pin_aux(port, bit, value) set_bit(reg_port(port), (bit), (value)) +#define toggle_pin_aux(port, bit) sbi(reg_pin(port), (bit)) + + +#define pin_up(io) set_pin_aux(io) +#define pin_high(io) set_pin_aux(io) + +#define pin_down(io) clear_pin_aux(io) +#define pin_low(io) clear_pin_aux(io) + +#define get_pin(io) read_pin_aux(io) +#define read_pin(io) read_pin_aux(io) + +#define pin_is_low(io) !read_pin_aux(io) +#define pin_is_high(io) read_pin_aux(io) + +#define set_pin(io, value) write_pin_aux(io, (value)) +#define write_pin(io, value) write_pin_aux(io, (value)) +#define toggle_pin(io) toggle_pin_aux(io) + + + +// setting pin direction +#define as_input_aux(port, bit) cbi(reg_ddr(port), (bit)) +#define as_output_aux(port, bit) sbi(reg_ddr(port), (bit)) +#define set_dir_aux(port, bit, dir) write_bit(reg_ddr(port), (bit), (dir)) + + +#define as_input(io) as_input_aux(io) +#define as_input_pu(io) do { as_input_aux(io); pullup_enable_aux(io); } while(0) + +#define as_output(io) as_output_aux(io) +#define set_dir(io, dir) set_dir_aux(io, (dir)) + + +// setting pullup +#define pullup_enable_aux(port, bit) sbi(reg_port(port), (bit)) +#define pullup_disable_aux(port, bit) cbi(reg_port(port), (bit)) +#define set_pullup_aux(port, bit, on) write_bit(reg_port(port), (bit), (on)) + + +#define pullup_enable(io) pullup_enable_aux(io) +#define pullup_on(io) pullup_enable_aux(io) + +#define pullup_disable(io) pullup_disable_aux(io) +#define pullup_off(io) pullup_disable_aux(io) + +#define set_pullup(io, on) set_pullup_aux(io, on) diff --git a/devel/lib/ws2812.h b/devel/lib/ws2812.h new file mode 100644 index 0000000..815d250 --- /dev/null +++ b/devel/lib/ws2812.h @@ -0,0 +1,77 @@ +#pragma once + +/** + Utils for driving a WS2812 (WS2812B) RGB LED strips. + + It's implemented as macros to avoid overhead when passing values, and to + enable driving multiple strips at once. There is over 1us of free time between + the colors, which can be used for some processing or color computation. + + To avoid bloating your code, try to reduce the nuýmber of invocations - + compute color and then send it. +*/ + +#include + +#include "pins.h" +#include "nsdelay.h" +#include "colors.h" + +/* Driver code for WS2812B */ + +// --- timing constraints (NS) --- + +#ifndef WS_T_1H +# define WS_T_1H 700 +#endif + +#ifndef WS_T_1L +# define WS_T_1L 150 +#endif + +#ifndef WS_T_0H +# define WS_T_0H 150 +#endif + +#ifndef WS_T_0L +# define WS_T_0L 700 +#endif + +#ifndef WS_T_LATCH +# define WS_T_LATCH 7000 +#endif + + +/** Wait long enough for the colors to show */ +#define ws_show() do { delay_ns_c(WS_T_LATCH, 0); } while(0) + + +/** Send one byte to the RGB strip */ +#define ws_send_byte(io, bb) do { \ + for (volatile int8_t __wsba_i = 7; __wsba_i >= 0; --__wsba_i) { \ + if ((bb) & (1 << __wsba_i)) { \ + pin_high(io_pack(io)); delay_ns_c(WS_T_1H, -2); \ + pin_low(io_pack(io)); delay_ns_c(WS_T_1L, -10); \ + } else { \ + pin_high(io_pack(io)); delay_ns_c(WS_T_0H, -2); \ + pin_low(io_pack(io)); delay_ns_c(WS_T_0L, -10); \ + } \ + } \ +} while(0) + + +/** Send R,G,B color to the strip */ +#define ws_send_rgb(io, r, g, b) do { \ + ws_send_byte(io_pack(io), g); \ + ws_send_byte(io_pack(io), r); \ + ws_send_byte(io_pack(io), b); \ +} while(0) + +/** Send a RGB struct */ +#define ws_send_xrgb(io, xrgb) ws_send_rgb(io_pack(io), (xrgb).r, (xrgb).g, (xrgb).b) + +/** Send color hex */ +#define ws_send_rgb24(io, rgb) ws_send_rgb(io_pack(io), rgb24_r(rgb), rgb24_g(rgb), rgb24_b(rgb)) +#define ws_send_rgb15(io, rgb) ws_send_rgb(io_pack(io), rgb15_r(rgb), rgb15_g(rgb), rgb15_b(rgb)) +#define ws_send_rgb12(io, rgb) ws_send_rgb(io_pack(io), rgb12_r(rgb), rgb12_g(rgb), rgb12_b(rgb)) +#define ws_send_rgb6(io, rgb) ws_send_rgb(io_pack(io), rgb6_r(rgb), rgb6_g(rgb), rgb6_b(rgb)) diff --git a/lib/debounce.h b/lib/debounce.h deleted file mode 100644 index 5301020..0000000 --- a/lib/debounce.h +++ /dev/null @@ -1,116 +0,0 @@ -#pragma once - -/** - An implementation of button debouncer. - - First, the system must be initialized: - - debounce_init(); - - A pin is registered for debouncing by calling - - #define BTN0 B,0 - #define BTN1 B,1 - - debounce_register(0, BTN0); - debounce_register(1, BTN1); - - Then periodically the tick function must be called: - - debounce_tick(); - - To check if pin is high, use - - debounce_get_pin(0); // registered as #0 - debounce_get_pin(1); // registered as #1 -*/ - -#include "pins.h" -#include "calc.h" -#include "avr/io.h" - -/** Number of ticks the pin must be in given state */ -#ifndef DEBOUNCE_TICKS -# define DEBOUNCE_TICKS 5 -#endif - -/** Max number of pins observed */ -#ifndef DEBOUNCE_SLOT_COUNT -#define DEBOUNCE_SLOT_COUNT 16 -#endif - - -/* Internal deboucer entry */ -typedef struct { - PORT_P port; - PIN_N bit; - uint8_t count; - bool state; -} debounce_slot_t; - - -/** Debounce data array */ -debounce_slot_t debounce_slots[DEBOUNCE_SLOT_COUNT]; - - -/** Init the debounce slots table */ -void debounce_init() -{ - for (uint8_t i = 0; i < DEBOUNCE_SLOT_COUNT; i++) { - debounce_slots[i] = { - .port = (PORT_P)0; - .bit = 0; - .state = 0; - .count = 0; - }; - } -} - - -/** Define a debounced pin (must be IO!) */ -inline void debounce_register_real(uint8_t number, PORT_P port, PIN_N bit) -{ - debounce_slots[number] = { - .port = port; - .bit = bit; - .count = 0; - .state = 0; - }; -} - -#define debounce_register(number, io) debounce_register_real((number), &io2port(io), io2n(io)) - - -/** Check debounced pins, should be called periodically. */ -void debounce_tick() -{ - for (uint8_t i = 0; i < DEBOUNCE_SLOT_COUNT; i++) { - - if (debounce_slots[i].port == 0) continue; // slot is unused - - // current pin value - bool value = read_bit_p(debounce_slots[i].port, debounce_slots[i].bit); - - if (value != debounce_slots[i].state) { - - // different pin state than last recorded state - if (debounce_slots[i].count < DEBOUNCE_TICKS) { - // increment - if (++debounce_slots[i].count == DEBOUNCE_TICKS) { - // overflown -> latch value - debounce_slots[i].state = value; - } - } - - } else { - debounce_slots[i].count = 0; // reset the counter - } - } -} - - -/** Get a value of debounced pin */ -inline bool debounce_get_pin(uint8_t number) -{ - return debounce_slots[number].state; -} diff --git a/new-pins-test/README.md b/new-pins-test/README.md deleted file mode 100644 index 11be5f1..0000000 --- a/new-pins-test/README.md +++ /dev/null @@ -1,31 +0,0 @@ -Keyboard Lamp -============= - -This is a keyboard lamp with adjustable brightness, that remembers last brightnbess level even when powered off. - -I've made it as a replacement for my broken ThinkLight. - -It uses ATtiny13, and the schematic is something like this: - - Vcc - | - ,---------------+ - | | - | +----u----+ | - '--| |--' - | ATMEL | Buttons - ,--[180R]-|<|---| |--BRT----o/ o---, - | LED2 | ATtiny | | - | -| 13 |--DIM----o/ o---+--- GND - GND | | - ,--| |----, - | +---------+ | LED1 - | | ,-|<|--[47R]-- Vcc - GND | | - '-[10k]-|< Transistor NPN - | - GND - -LED1 is the bright white LED, LED2 is an indicator that the brightness has been saved. You can leave LED2 out if you want. - -**Fuses** and other settings can be found in the Makefile. diff --git a/new-pins-test/lib b/new-pins-test/lib deleted file mode 120000 index da7aca1..0000000 --- a/new-pins-test/lib +++ /dev/null @@ -1 +0,0 @@ -/home/ondra/devel/avr/avr-projects/lib \ No newline at end of file diff --git a/new-pins-test/main.c b/new-pins-test/main.c deleted file mode 100644 index 3c8e632..0000000 --- a/new-pins-test/main.c +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "lib/meta.h" -#include "lib/pins.h" - -/** - * +--u--+ - * RST --| |-- Vcc - * SAVE LED : PB3 --| t13 |-- PB2 : BTN: HIGH - * N.C. : PB4 --| |-- PB1 : BTN: LOW - * GND --| |-- PB0 : LED - * +-----+ - */ - - -// pins config -#define LED B,0 -#define BTN_DOWN B,1 -#define BTN_UP B,2 -#define INDICATOR B,3 - -#define btn_on() pin_is_low(BTN_UP) - - -/** Initialize IO ports. */ -void SECTION(".init8") init_io(void) -{ - as_output(LED); - as_output(INDICATOR); - - as_input(BTN_DOWN); - as_input(BTN_UP); - - pullup_on(BTN_DOWN); - pullup_on(BTN_UP); - - // initialize the timer - - // Fast PWM mode, Output to OC0A - OCR0A = 32; - TCCR0A = _BV(WGM00) | _BV(WGM01) | _BV(COM0A1); - TCCR0B = _BV(CS00); -} - - -#define BRIGHTNESS_LEN 121 - -const uint8_t BRIGHTNESS[] PROGMEM = { - 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, - 6, 6, 6, 7, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 13, 14, 14, - 15, 16, 17, 18, 20, 21, 22, 24, 26, 27, 28, 30, 31, 32, 34, - 35, 36, 38, 39, 40, 41, 42, 44, 45, 46, 48, 49, 50, 52, 54, - 56, 58, 59, 61, 63, 65, 67, 69, 71, 72, 74, 76, 78, 80, 82, - 85, 88, 90, 92, 95, 98, 100, 103, 106, 109, 112, 116, 119, - 122, 125, 129, 134, 138, 142, 147, 151, 156, 160, 165, 170, - 175, 180, 185, 190, 195, 200, 207, 214, 221, 228, 234, 241, - 248, 255 -}; - -#define apply_brightness(level) OCR0A = pgm_read_byte( & BRIGHTNESS[level] ) - - -/** - * Main function - */ -void main() -{ - bool changed = 0; - bool changed_since_last_save = 0; - - uint8_t savetimer = 0; - - uint8_t level = eeprom_read_byte((uint8_t *) 0); - - if (level >= BRIGHTNESS_LEN) - level = BRIGHTNESS_LEN - 1; - else if (level == 0) - level = BRIGHTNESS_LEN / 2; - - apply_brightness(level); - - while (1) { - if (btn_on() && level < BRIGHTNESS_LEN - 1) { - level++; - changed = 1; - } - - if (!btn_on() && level > 1) { - level--; - changed = 1; - } - - if (changed) { - changed = 0; - savetimer = 0; - changed_since_last_save = 1; - apply_brightness(level); - } - - _delay_ms(20); - savetimer++; - - if (savetimer >= 50 && changed_since_last_save) { - changed_since_last_save = 0; - savetimer = 0; - - pin_high(INDICATOR); - eeprom_update_byte((uint8_t*) 0, level); - _delay_ms(10); - pin_low(INDICATOR); - } - } -} diff --git a/pov-led-globe/globe-timed-experimental/utils.h b/pov-led-globe/globe-timed-experimental/utils.h deleted file mode 100644 index 4ab82a1..0000000 --- a/pov-led-globe/globe-timed-experimental/utils.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -// general macros -#define SECTION(pos) __attribute__((naked, used, section(pos))) - - -// pin manipulation -#define sbi(port, bit) (port) |= _BV(bit) -#define cbi(port, bit) (port) &= ~ _BV(bit) - -#define set_bit(port, bit, value) (port) = (((port) & ~_BV(bit)) | ((value) << (bit))) -#define get_bit(port, bit) (((port) >> (bit)) & 1) - -#define bus_pulse(port, bit) { sbi(port, bit); cbi(port, bit); } diff --git a/dice/Makefile b/projects/dice/Makefile similarity index 100% rename from dice/Makefile rename to projects/dice/Makefile diff --git a/dice/README.md b/projects/dice/README.md similarity index 100% rename from dice/README.md rename to projects/dice/README.md diff --git a/dice/main.c b/projects/dice/main.c similarity index 100% rename from dice/main.c rename to projects/dice/main.c diff --git a/keyboard-lamp/Makefile b/projects/keyboard-lamp/Makefile similarity index 100% rename from keyboard-lamp/Makefile rename to projects/keyboard-lamp/Makefile diff --git a/keyboard-lamp/README.md b/projects/keyboard-lamp/README.md similarity index 100% rename from keyboard-lamp/README.md rename to projects/keyboard-lamp/README.md diff --git a/keyboard-lamp/main.c b/projects/keyboard-lamp/main.c similarity index 100% rename from keyboard-lamp/main.c rename to projects/keyboard-lamp/main.c diff --git a/new-pins-test/utils.h b/projects/keyboard-lamp/utils.h similarity index 100% rename from new-pins-test/utils.h rename to projects/keyboard-lamp/utils.h diff --git a/rgb-led-strip/arduino-ws-anim-rainbow/README.md b/rgb-led-strip/arduino-ws-anim-rainbow/README.md deleted file mode 100644 index 836bc8f..0000000 --- a/rgb-led-strip/arduino-ws-anim-rainbow/README.md +++ /dev/null @@ -1,13 +0,0 @@ -WS2812B RGB LED strip driving code -================================== - -This code is meant for 16MHz Arduino, but should work on any 16MHz AVR. It is in plain C, not the Arduino language. - -All you need is `ws_driver.c` and `ws_driver.h`, and `config.c` where you define the port / pin information. - -Connection ----------- - -Digital pin 8 on Arduino (PB0) is connected via a 200-500 R to WS2812B data input. In parallel to the LED strip is a 500-1000 uF capacitor that takes care of smoothening the power supply. Without the cap, the LEDs will flicker. - -It is recommended to use stronger power supply for the LED strip, a 30-led one takes around to 1A when fully powered. diff --git a/rgb-led-strip/arduino-ws-anim-rainbow/lib b/rgb-led-strip/arduino-ws-anim-rainbow/lib deleted file mode 120000 index da7aca1..0000000 --- a/rgb-led-strip/arduino-ws-anim-rainbow/lib +++ /dev/null @@ -1 +0,0 @@ -/home/ondra/devel/avr/avr-projects/lib \ No newline at end of file diff --git a/rgb-led-strip/arduino-ws-gamepad/README.md b/rgb-led-strip/arduino-ws-gamepad/README.md deleted file mode 100644 index 836bc8f..0000000 --- a/rgb-led-strip/arduino-ws-gamepad/README.md +++ /dev/null @@ -1,13 +0,0 @@ -WS2812B RGB LED strip driving code -================================== - -This code is meant for 16MHz Arduino, but should work on any 16MHz AVR. It is in plain C, not the Arduino language. - -All you need is `ws_driver.c` and `ws_driver.h`, and `config.c` where you define the port / pin information. - -Connection ----------- - -Digital pin 8 on Arduino (PB0) is connected via a 200-500 R to WS2812B data input. In parallel to the LED strip is a 500-1000 uF capacitor that takes care of smoothening the power supply. Without the cap, the LEDs will flicker. - -It is recommended to use stronger power supply for the LED strip, a 30-led one takes around to 1A when fully powered. diff --git a/rgb-led-strip/arduino-ws-gamepad/config.h b/rgb-led-strip/arduino-ws-gamepad/config.h deleted file mode 100644 index 1b46c1d..0000000 --- a/rgb-led-strip/arduino-ws-gamepad/config.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "lib/arduino_pins2.h" - -#define WSDATA_in D8_in -#define WSDATA_out D8_out -#define WSDATA_dir D8_dir - -#define WS_T_1H 700 -#define WS_T_1L 150 -#define WS_T_0H 150 -#define WS_T_0L 700 -#define WS_T_LATCH 6000 - -# define DEBOUNCE_COUNT 63 -#define DEBOUNCE_SLOT_COUNT 4 diff --git a/rgb-led-strip/arduino-ws-gamepad/gamepad_pins.h b/rgb-led-strip/arduino-ws-gamepad/gamepad_pins.h deleted file mode 100644 index 6f8aaa8..0000000 --- a/rgb-led-strip/arduino-ws-gamepad/gamepad_pins.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "lib/arduino_pins.h" - -#define PIN_LEFT PIN_D2 -#define DDR_LEFT DDR_D2 -#define PORT_LEFT PORT_D2 -#define LEFT D2 - -#define PIN_RIGHT PIN_D3 -#define DDR_RIGHT DDR_D3 -#define PORT_RIGHT PORT_D3 -#define RIGHT D3 - -#define PIN_UP PIN_D4 -#define DDR_UP DDR_D4 -#define PORT_UP PORT_D4 -#define UP D4 - -#define PIN_DOWN PIN_D5 -#define DDR_DOWN DDR_D5 -#define PORT_DOWN PORT_D5 -#define DOWN D5 diff --git a/rgb-led-strip/arduino-ws-gamepad/lib b/rgb-led-strip/arduino-ws-gamepad/lib deleted file mode 120000 index da7aca1..0000000 --- a/rgb-led-strip/arduino-ws-gamepad/lib +++ /dev/null @@ -1 +0,0 @@ -/home/ondra/devel/avr/avr-projects/lib \ No newline at end of file diff --git a/rgb-led-strip/arduino-ws-gamepad/main.c b/rgb-led-strip/arduino-ws-gamepad/main.c deleted file mode 100644 index a80d6ff..0000000 --- a/rgb-led-strip/arduino-ws-gamepad/main.c +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include "lib/arduino_pins2.h" -#include "lib/utils.h" -#include "lib/ws_driver.h" -#include "lib/debounce.h" - -#include "config.h" -#include "gamepad_pins.h" - - -void init_io() SECTION(".init8") -{ - // WS2182B data pin as output - set_bit(WS_dir, OUT); - - // enable pullups on input pins - set_bit(LEFT_out); - sbi(PORT_RIGHT, RIGHT); - sbi(PORT_UP, UP); - sbi(PORT_DOWN, DOWN); - - // init timer - TCCR0A = _BV(WGM01); // CTC mode - TCCR0B = _BV(CS02) | _BV(CS00); // prescaler 1024 - OCR0A = 250; // interrupt every 16 ms - sbi(TIMSK0, OCIE0A); // enable interrupt from timer - - // set up debouncer - debounce_register(0, &PIN) -} - - -/** timer 0 interrupt vector */ -ISR(TIM0_COMPA_vect) -{ - debounce_tick(); -} - - - -typedef struct -{ - uint8_t r, - uint8_t g, - uint8_t b, -} color_t; - -#define RED {.r=0xFF, .g=0x00, .b=0x00} -#define GREEN {.r=0xFF, .g=0x00, .b=0x00} -#define BLUE {.r=0xFF, .g=0x00, .b=0x00} - -#define YELLOW {.r=0xFF, .g=0xFF, .b=0x00} -#define MAGENTA {.r=0xFF, .g=0x00, .b=0xFF} -#define CYAN {.r=0x00, .g=0xFF, .b=0xFF} - -#define BLACK {.r=0x00, .g=0x00, .b=0x00} -#define WHITE {.r=0xFF, .g=0xFF, .b=0xFF} - - -#define BULB_COUNT 4; - -color_t bulbs[BULB_COUNT]; - -void show_lights() -{ - for (uint8_t i = 0; i < BULB_COUNT; i++) { - ws_send_rgb(bulbs[i].r, bulbs[i].g, bulbs[i].b); - } - ws_show(); -} - - -void main() -{ - while (1) { - show_lights(); - } -} diff --git a/test-passportbyref/Makefile b/test-passportbyref/Makefile deleted file mode 100644 index 9f4c5f1..0000000 --- a/test-passportbyref/Makefile +++ /dev/null @@ -1,153 +0,0 @@ - -MCU = attiny13 - -F_CPU = 9600000 - -LFUSE = 0x72 -HFUSE = 0xFF - -MAIN = main.c - -## If you've split your program into multiple files, -## include the additional .c source (in same directory) here -## (and include the .h files in your foo.c) -LOCAL_SOURCE = - -## Here you can link to one more directory (and multiple .c files) -# EXTRA_SOURCE_DIR = ../AVR-Programming-Library/ -EXTRA_SOURCE_DIR = -EXTRA_SOURCE_FILES = - - - -##########------------------------------------------------------########## -########## Programmer Defaults ########## -########## Set up once, then forget about it ########## -########## (Can override. See bottom of file.) ########## -##########------------------------------------------------------########## - -PROGRAMMER_TYPE = dragon_isp -PROGRAMMER_ARGS = - - -##########------------------------------------------------------########## -########## Makefile Magic! ########## -########## Summary: ########## -########## We want a .hex file ########## -########## Compile source files into .elf ########## -########## Convert .elf file into .hex ########## -########## You shouldn't need to edit below. ########## -##########------------------------------------------------------########## - -## Defined programs / locations -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -AVRSIZE = avr-size -AVRDUDE = sudo avrdude - -## Compilation options, type man avr-gcc if you're curious. -CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -Os -I. -I$(EXTRA_SOURCE_DIR) -CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -CFLAGS += -Wall -Wno-main -CFLAGS += -g2 -ggdb -CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--relax -CFLAGS += -std=gnu99 -# CFLAGS += -lm -## CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf -## CFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf - -## Lump target and extra source files together -TARGET = $(strip $(basename $(MAIN))) -SRC = $(TARGET).c -EXTRA_SOURCE = $(addprefix $(EXTRA_SOURCE_DIR), $(EXTRA_SOURCE_FILES)) -SRC += $(EXTRA_SOURCE) -SRC += $(LOCAL_SOURCE) - -## List of all header files -HEADERS = $(SRC:.c=.h) - -## For every .c file, compile an .o object file -OBJ = $(SRC:.c=.o) - -## Generic Makefile targets. (Only .hex file is necessary) -all: $(TARGET).hex size - -%.hex: %.elf - $(OBJCOPY) -R .eeprom -O ihex $< $@ - -%.elf: $(SRC) - $(CC) $(CFLAGS) $(SRC) --output $@ - -%.eeprom: %.elf - $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ - -debug: - @echo - @echo "Source files:" $(SRC) - @echo "MCU, F_CPU, BAUD:" $(MCU), $(F_CPU), $(BAUD) - @echo - -# Optionally create listing file from .elf -# This creates approximate assembly-language equivalent of your code. -# Useful for debugging time-sensitive bits, -# or making sure the compiler does what you want. -disassemble: $(TARGET).lst - -dis: disassemble - -eeprom: $(TARGET).eeprom - -%.lst: %.elf - $(OBJDUMP) -S $< > $@ - -# Optionally show how big the resulting program is -size: $(TARGET).elf - $(AVRSIZE) -C --mcu=$(MCU) $(TARGET).elf - -clean: - rm -f $(TARGET).elf $(TARGET).hex $(TARGET).obj \ - $(TARGET).o $(TARGET).d $(TARGET).eep $(TARGET).lst \ - $(TARGET).lss $(TARGET).sym $(TARGET).map $(TARGET)~ \ - $(TARGET).eeprom - -squeaky_clean: - rm -f *.elf *.hex *.obj *.o *.d *.eep *.lst *.lss *.sym *.map *~ - - -##########------------------------------------------------------########## -########## Programmer-specific details ########## -########## Flashing code to AVR using avrdude ########## -##########------------------------------------------------------########## - -flash: $(TARGET).hex - $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$< - -flash_eeprom: $(TARGET).eeprom - $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U eeprom:w:$< - -terminal: - $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nt - - -flash_dragon_isp: PROGRAMMER_TYPE = dragon_isp -flash_dragon_isp: PROGRAMMER_ARGS = -flash_dragon_isp: flash - - -##########------------------------------------------------------########## -########## Fuse settings and suitable defaults ########## -##########------------------------------------------------------########## - -## Generic -FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m - -fuses: - $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) \ - $(PROGRAMMER_ARGS) $(FUSE_STRING) -show_fuses: - $(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -nv - -## Called with no extra definitions, sets to defaults -set_default_fuses: FUSE_STRING = -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m -set_default_fuses: fuses diff --git a/test-passportbyref/README.md b/test-passportbyref/README.md deleted file mode 100644 index 11be5f1..0000000 --- a/test-passportbyref/README.md +++ /dev/null @@ -1,31 +0,0 @@ -Keyboard Lamp -============= - -This is a keyboard lamp with adjustable brightness, that remembers last brightnbess level even when powered off. - -I've made it as a replacement for my broken ThinkLight. - -It uses ATtiny13, and the schematic is something like this: - - Vcc - | - ,---------------+ - | | - | +----u----+ | - '--| |--' - | ATMEL | Buttons - ,--[180R]-|<|---| |--BRT----o/ o---, - | LED2 | ATtiny | | - | -| 13 |--DIM----o/ o---+--- GND - GND | | - ,--| |----, - | +---------+ | LED1 - | | ,-|<|--[47R]-- Vcc - GND | | - '-[10k]-|< Transistor NPN - | - GND - -LED1 is the bright white LED, LED2 is an indicator that the brightness has been saved. You can leave LED2 out if you want. - -**Fuses** and other settings can be found in the Makefile. diff --git a/test-passportbyref/lib b/test-passportbyref/lib deleted file mode 120000 index da7aca1..0000000 --- a/test-passportbyref/lib +++ /dev/null @@ -1 +0,0 @@ -/home/ondra/devel/avr/avr-projects/lib \ No newline at end of file diff --git a/test-passportbyref/main.c b/test-passportbyref/main.c deleted file mode 100644 index acd5225..0000000 --- a/test-passportbyref/main.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -void led_on(volatile uint8_t* portp, uint8_t pinn) { - *portp |= _BV(pinn); -} - -void led_off(volatile uint8_t* portp, uint8_t pinn) { - *portp &= ~ _BV(pinn); -} - -void main() -{ - led_on(&PORTB, 3); - led_off(&PORTB, 5); - led_on(&DDRB, 3); -}