From a7aa3be11d15728de8c6f50334d7892cae942394 Mon Sep 17 00:00:00 2001 From: Alex Filippov Date: Wed, 18 May 2016 19:57:27 +0600 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20UsbTitle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rmodule/nrf24l01/nRF24L01.h | 0 Rmodule/nrf24l01/nrf24l01.c | 0 Rmodule/nrf24l01/nrf24l01registers.h | 0 Rmodule/spi/spi.c | 0 Rmodule/spi/spi.h | 0 Smodule/Smodule.aps | 0 Smodule/default/Makefile | 0 Smodule/main.c | 0 Smodule/nrf24l01/nRF24L01.h | 0 Smodule/nrf24l01/nrf24l01.c | 0 Smodule/nrf24l01/nrf24l01registers.h | 0 Smodule/res/strings.h | 0 Smodule/smodule.aws | 0 Smodule/spi/spi.c | 0 Smodule/spi/spi.h | 0 Smodule/uart/uart.c | 0 Smodule/uart/uart.h | 0 Smodule/uart/uart_addon.c | 0 Smodule/uart/uart_addon.h | 0 UsbTitle/UsbTitle.ino | 78 ++++++++++++++++++++++++++++ UsbTitle/eeprom.bat | 1 + UsbTitle/eeprom0.hex | 17 ++++++ 22 files changed, 96 insertions(+) mode change 100644 => 100755 Rmodule/nrf24l01/nRF24L01.h mode change 100644 => 100755 Rmodule/nrf24l01/nrf24l01.c mode change 100644 => 100755 Rmodule/nrf24l01/nrf24l01registers.h mode change 100644 => 100755 Rmodule/spi/spi.c mode change 100644 => 100755 Rmodule/spi/spi.h mode change 100644 => 100755 Smodule/Smodule.aps mode change 100644 => 100755 Smodule/default/Makefile mode change 100644 => 100755 Smodule/main.c mode change 100644 => 100755 Smodule/nrf24l01/nRF24L01.h mode change 100644 => 100755 Smodule/nrf24l01/nrf24l01.c mode change 100644 => 100755 Smodule/nrf24l01/nrf24l01registers.h mode change 100644 => 100755 Smodule/res/strings.h mode change 100644 => 100755 Smodule/smodule.aws mode change 100644 => 100755 Smodule/spi/spi.c mode change 100644 => 100755 Smodule/spi/spi.h mode change 100644 => 100755 Smodule/uart/uart.c mode change 100644 => 100755 Smodule/uart/uart.h mode change 100644 => 100755 Smodule/uart/uart_addon.c mode change 100644 => 100755 Smodule/uart/uart_addon.h create mode 100755 UsbTitle/UsbTitle.ino create mode 100755 UsbTitle/eeprom.bat create mode 100755 UsbTitle/eeprom0.hex diff --git a/Rmodule/nrf24l01/nRF24L01.h b/Rmodule/nrf24l01/nRF24L01.h old mode 100644 new mode 100755 diff --git a/Rmodule/nrf24l01/nrf24l01.c b/Rmodule/nrf24l01/nrf24l01.c old mode 100644 new mode 100755 diff --git a/Rmodule/nrf24l01/nrf24l01registers.h b/Rmodule/nrf24l01/nrf24l01registers.h old mode 100644 new mode 100755 diff --git a/Rmodule/spi/spi.c b/Rmodule/spi/spi.c old mode 100644 new mode 100755 diff --git a/Rmodule/spi/spi.h b/Rmodule/spi/spi.h old mode 100644 new mode 100755 diff --git a/Smodule/Smodule.aps b/Smodule/Smodule.aps old mode 100644 new mode 100755 diff --git a/Smodule/default/Makefile b/Smodule/default/Makefile old mode 100644 new mode 100755 diff --git a/Smodule/main.c b/Smodule/main.c old mode 100644 new mode 100755 diff --git a/Smodule/nrf24l01/nRF24L01.h b/Smodule/nrf24l01/nRF24L01.h old mode 100644 new mode 100755 diff --git a/Smodule/nrf24l01/nrf24l01.c b/Smodule/nrf24l01/nrf24l01.c old mode 100644 new mode 100755 diff --git a/Smodule/nrf24l01/nrf24l01registers.h b/Smodule/nrf24l01/nrf24l01registers.h old mode 100644 new mode 100755 diff --git a/Smodule/res/strings.h b/Smodule/res/strings.h old mode 100644 new mode 100755 diff --git a/Smodule/smodule.aws b/Smodule/smodule.aws old mode 100644 new mode 100755 diff --git a/Smodule/spi/spi.c b/Smodule/spi/spi.c old mode 100644 new mode 100755 diff --git a/Smodule/spi/spi.h b/Smodule/spi/spi.h old mode 100644 new mode 100755 diff --git a/Smodule/uart/uart.c b/Smodule/uart/uart.c old mode 100644 new mode 100755 diff --git a/Smodule/uart/uart.h b/Smodule/uart/uart.h old mode 100644 new mode 100755 diff --git a/Smodule/uart/uart_addon.c b/Smodule/uart/uart_addon.c old mode 100644 new mode 100755 diff --git a/Smodule/uart/uart_addon.h b/Smodule/uart/uart_addon.h old mode 100644 new mode 100755 diff --git a/UsbTitle/UsbTitle.ino b/UsbTitle/UsbTitle.ino new file mode 100755 index 0000000..81ce109 --- /dev/null +++ b/UsbTitle/UsbTitle.ino @@ -0,0 +1,78 @@ +#include +#include +#include "LedControl.h" + +/* + Now we need a LedControl to work with. + pin 2 is connected to the DataIn + pin 1 is connected to the CLK + pin 0 is connected to LOAD + We have only a single MAX72XX. + */ + +LedControl lc=LedControl(2,1,0,1); + +void setup() { + DigiUSB.begin(); + /* + The MAX72XX is in power-saving mode on startup, + we have to do a wakeup call + */ + lc.shutdown(0,false); + /* Set the brightness to a medium values */ + lc.setIntensity(0,0); + /* and clear the display */ + lc.clearDisplay(0); + delay(1000); +} + +void loop() { + byte lastRead; + byte lastCmd = 0xFF; + byte value; + DigiUSB.refresh(); + while (true) { // loop forever + if (DigiUSB.available()) { + // something to read + lastRead = DigiUSB.read(); + if (lastRead >= 0x20 && lastRead<=0x7F){ + if (lastCmd == 0xFF){ // Если ранее команд не было, значит считываем команду + lastCmd = lastRead; + }else{ // команда есть, операнд считали, выполняем + if (lastCmd >=0x41 && lastCmd <=0x48){ // команда установки в сегменте нужного кода ABCDEFGH + value = EEPROM.read(lastRead); + lc.setRow(0, 7-(lastCmd-0x41), value+0x80); + }else if (lastCmd >=0x61 && lastCmd <=0x68){ // команда установки в сегменте нужного кода abcdefgh + value = EEPROM.read(lastRead); + lc.setRow(0, 7-(lastCmd-0x61), value); + }else if (lastCmd == 0x69){ // команда яркости i 0..9abcdef + if (lastRead >=0x30 && lastRead <= 0x39){ + lc.setIntensity(0, lastRead-0x30); + }else if (lastRead >=0x61 && lastRead <= 0x66){ + lc.setIntensity(0, lastRead-0x57); + } + }else if (lastCmd == 0x6C){ // команда количества разрядов l 0..7 + if (lastRead >=0x30 && lastRead <= 0x37){ + lc.setScanLimit(0, lastRead-0x30); + } + }else if (lastCmd == 0x78){ // команда очистки экрана x0 + if (lastRead == 0x30){ + lc.clearDisplay(0); + } + }else if (lastCmd == 0x73){ // команда s0..1 + if (lastRead == 0x30){ + lc.shutdown(0,false); + }else{ + lc.shutdown(0,true); + } + } + lastCmd = 0xFF; + } + }else{ + lastCmd = 0xFF; + } + } + // refresh the usb port for 10 milliseconds + DigiUSB.delay(10); + } +} diff --git a/UsbTitle/eeprom.bat b/UsbTitle/eeprom.bat new file mode 100755 index 0000000..4e9acc2 --- /dev/null +++ b/UsbTitle/eeprom.bat @@ -0,0 +1 @@ +avrdude -C../etc/avrdude.conf -cstk500v1 -pt85 -PCOM19 -b19200 -e -Ueeprom:w:eeprom0.hex:i \ No newline at end of file diff --git a/UsbTitle/eeprom0.hex b/UsbTitle/eeprom0.hex new file mode 100755 index 0000000..263c7a0 --- /dev/null +++ b/UsbTitle/eeprom0.hex @@ -0,0 +1,17 @@ +:20000000000000000000000000000000000000000000000000000000000000000000000000 +:20002000000000000000000000006300000100007E306D79335B5F707F7B000000090000E0 +:200040000077004E004F475E37003C000E00760067000000003E0000003B000000000008C0 +:20006000007D1F0D3D6F0000170438000600151D007305000F1C00000000000000000000A0 +:20008000000000000000000000000000000000000000000000000000000000000000000080 +:2000A000000000000000000000000000000000000000000000000000000000000000000060 +:2000C000000000000000000000000000000000000000000000000000000000000000000040 +:2000E000000000000000000000000000000000000000000000000000000000000000000020 +:20010000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +:20012000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDF +:20014000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBF +:20016000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9F +:20018000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7F +:2001A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5F +:2001C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3F +:2001E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1F +:00000001FF