From 4914d22b052c990a1c0e5f11074058433c45328f Mon Sep 17 00:00:00 2001 From: Noa Sakurajin Date: Sun, 24 Jan 2021 20:46:07 +0100 Subject: [PATCH] preparations for multilingual examples --- .scripts/doxygen_multilang.sh | 2 + .../LCDemo7Segment/LCDemo7Segment.ino | 0 .../LedControllerDemoCounting.ino | 0 .../LedControllerDemoHwSPI.ino | 0 .../LedControllerDemoRocket.ino | 0 .../LedControllerDemoRocketMulti.ino | 0 .../german/LCDemo7Segment/LCDemo7Segment.ino | 93 ++++++++++ .../LedControllerDemoCounting.ino | 174 ++++++++++++++++++ .../LedControllerDemoHwSPI.ino | 131 +++++++++++++ .../LedControllerDemoRocket.ino | 137 ++++++++++++++ .../LedControllerDemoRocketMulti.ino | 146 +++++++++++++++ 11 files changed, 683 insertions(+) rename examples/{ => english}/LCDemo7Segment/LCDemo7Segment.ino (100%) rename examples/{ => english}/LedControllerDemoCounting/LedControllerDemoCounting.ino (100%) rename examples/{ => english}/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino (100%) rename examples/{ => english}/LedControllerDemoRocket/LedControllerDemoRocket.ino (100%) rename examples/{ => english}/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino (100%) create mode 100644 examples/german/LCDemo7Segment/LCDemo7Segment.ino create mode 100644 examples/german/LedControllerDemoCounting/LedControllerDemoCounting.ino create mode 100755 examples/german/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino create mode 100755 examples/german/LedControllerDemoRocket/LedControllerDemoRocket.ino create mode 100644 examples/german/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino diff --git a/.scripts/doxygen_multilang.sh b/.scripts/doxygen_multilang.sh index 69ffdfd4..6a440005 100755 --- a/.scripts/doxygen_multilang.sh +++ b/.scripts/doxygen_multilang.sh @@ -7,6 +7,7 @@ OUTPUT_LANGUAGES=("english" "german") OLD_LANGAUGE="English" OUTPUT_LANGUAGE_STRING="OUTPUT_LANGUAGE = " HTML_DIR="HTML_OUTPUT = html" +EXAMPLE_DIR="EXAMPLE_PATH = examples" #the base folder for the doxygen output DOXYGEN_BASE="doc" @@ -20,6 +21,7 @@ do #replace the language and add specific subfolder sed -i "s/$OUTPUT_LANGUAGE_STRING$OLD_LANGAUGE/$OUTPUT_LANGUAGE_STRING$lang/g" Doxyfile.$lang sed -i "s/$HTML_DIR/$HTML_DIR\/$lang/g" Doxyfile.$lang + sed -i "s/$EXAMPLE_DIR/$EXAMPLE_DIR\/$lang/g" Doxyfile.$lang #check if replacement worked as intended grep OUTPUT_LANGUAGE Doxyfile.$lang diff --git a/examples/LCDemo7Segment/LCDemo7Segment.ino b/examples/english/LCDemo7Segment/LCDemo7Segment.ino similarity index 100% rename from examples/LCDemo7Segment/LCDemo7Segment.ino rename to examples/english/LCDemo7Segment/LCDemo7Segment.ino diff --git a/examples/LedControllerDemoCounting/LedControllerDemoCounting.ino b/examples/english/LedControllerDemoCounting/LedControllerDemoCounting.ino similarity index 100% rename from examples/LedControllerDemoCounting/LedControllerDemoCounting.ino rename to examples/english/LedControllerDemoCounting/LedControllerDemoCounting.ino diff --git a/examples/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino b/examples/english/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino similarity index 100% rename from examples/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino rename to examples/english/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino diff --git a/examples/LedControllerDemoRocket/LedControllerDemoRocket.ino b/examples/english/LedControllerDemoRocket/LedControllerDemoRocket.ino similarity index 100% rename from examples/LedControllerDemoRocket/LedControllerDemoRocket.ino rename to examples/english/LedControllerDemoRocket/LedControllerDemoRocket.ino diff --git a/examples/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino b/examples/english/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino similarity index 100% rename from examples/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino rename to examples/english/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino diff --git a/examples/german/LCDemo7Segment/LCDemo7Segment.ino b/examples/german/LCDemo7Segment/LCDemo7Segment.ino new file mode 100644 index 00000000..6189146d --- /dev/null +++ b/examples/german/LCDemo7Segment/LCDemo7Segment.ino @@ -0,0 +1,93 @@ +/** + * @file LCDemo7Segment.ino + * @author Noa Sakurajin (noasakurajin@web.de) + * @brief using the ledcontroller with 7-segment displays + * @version 0.1 + * @date 2020-12-30 + * + * @copyright Copyright (c) 2020 + * + */ + +//We always have to include the library +#include "LedController.hpp" + +/* + You might need to change the following 3 Variables depending on your board. + pin 15 is connected to the DataIn + pin 14 is connected to the CLK + pin 13 is connected to LOAD/ChipSelect +*/ +#define DIN 15 +#define CS 13 +#define CLK 14 + +/* + Now we need a LedControl to work with. + We have only a single MAX72XX. + */ +LedController<1,1> lc; + +/* we always wait a bit between updates of the display */ +unsigned long delaytime=250; + +void setup() { + + lc=LedController<1,1>(CS,CLK,DIN); + + /* + The MAX72XX is in power-saving mode on startup, + we have to do a wakeup call + */ + lc.activateAllSegments(); + /* Set the brightness to a medium values */ + lc.setIntensity(8); + /* and clear the display */ + lc.clearMatrix(); +} + + +/* + This method will display the characters for the + word "Arduino" one after the other on digit 0. + */ +void writeArduinoOn7Segment() { + lc.setChar(0,0,'a',false); + delay(delaytime); + lc.setRow(0,0,0x05); + delay(delaytime); + lc.setChar(0,0,'d',false); + delay(delaytime); + lc.setRow(0,0,0x1c); + delay(delaytime); + lc.setRow(0,0,B00010000); + delay(delaytime); + lc.setRow(0,0,0x15); + delay(delaytime); + lc.setRow(0,0,0x1D); + delay(delaytime); + lc.clearMatrix(); + delay(delaytime); +} + +/* + This method will scroll all the hexa-decimal + numbers and letters on the display. You will need at least + four 7-Segment digits. otherwise it won't really look that good. + */ +void scrollDigits() { + for(int i=0;i<13;i++) { + lc.setDigit(0,3,i,false); + lc.setDigit(0,2,i+1,false); + lc.setDigit(0,1,i+2,false); + lc.setDigit(0,0,i+3,false); + delay(delaytime); + } + lc.clearMatrix(); + delay(delaytime); +} + +void loop() { + writeArduinoOn7Segment(); + scrollDigits(); +} diff --git a/examples/german/LedControllerDemoCounting/LedControllerDemoCounting.ino b/examples/german/LedControllerDemoCounting/LedControllerDemoCounting.ino new file mode 100644 index 00000000..f029eb17 --- /dev/null +++ b/examples/german/LedControllerDemoCounting/LedControllerDemoCounting.ino @@ -0,0 +1,174 @@ +/** + * @file LedControllerDemoCounting.ino + * @author Noa Sakurajin (noasakurajin@web.de) + * @brief counting up on an led matrix + * @version 0.1 + * @date 2020-12-30 + * + * @copyright Copyright (c) 2020 + * + */ + +#include "LedController.hpp" + +//the pin where the chip select is connected to +#define CS 15 + +#define Segments 4 + +#define delayTime 200 // Delay between Frames + +LedController lc; + +//these are just some digits to display numbers on the matrix +ByteBlock digits[10] = { + { + B00000000, + B00011000, + B00100100, + B01000010, + B01000010, + B00100100, + B00011000, + B00000000 + }, { + B00000000, + B00011100, + B00101100, + B01001100, + B00001100, + B00001100, + B00001100, + B00000000 + }, { + B00000000, + B00111000, + B01101100, + B00011000, + B00110000, + B01100000, + B01111110, + B00000000 + }, { + B00000000, + B00111100, + B01100110, + B00001100, + B00000110, + B01100110, + B00111100, + B00000000 + }, { + B00000000, + B01100000, + B01100000, + B01101000, + B01111110, + B00001000, + B00001000, + B00000000 + }, { + B00000000, + B01111110, + B01100000, + B01111000, + B00000110, + B01100110, + B00111100, + B00000000 + }, { + B00000000, + B00001100, + B00111000, + B01100000, + B01111100, + B01100110, + B00111100, + B00000000 + }, { + B00000000, + B01111110, + B00000110, + B00001100, + B00011000, + B00110000, + B01100000, + B00000000 + }, { + B00000000, + B00111100, + B00100100, + B00011000, + B01100110, + B01000010, + B00111100, + B00000000 + }, { + B00000000, + B00111100, + B01100110, + B00111110, + B00000110, + B00011100, + B00110000, + B00000000 + } +}; + +//this function sets the matrix to a given number +void setLEDs (unsigned int number) { + //the loop is used to split the given number and set the right digit on the matix + unsigned int places[4]; + + for(unsigned int i = 0;i < 4;i++){ + unsigned int divisor = 1; + for(unsigned int j=0;j < i;j++){ + divisor *= 10; + } + + places[3-i] = number/divisor % 10; + lc.displayOnSegment(3-i,digits[places[3-i]]); + } + +} + +//this function switches a led to have a +void switchLED(){ + static bool LEDON = false; + if(LEDON){ + digitalWrite(13, LOW); + }else{ + digitalWrite(13, HIGH); + } + LEDON = !LEDON; +} + +void setup(){ + + //create a ledcontroller with a hardware spi and one row + lc = LedController(CS); + + //enable the led + pinMode(13, OUTPUT); + + //rotate all digits by 180 degress to display them correctly + //you could leave this but then the orientation would be wrong + for(unsigned int i = 0; i < 10; i++){ + digits[i] = lc.rotate180(digits[i]); + } + +} + +void loop(){ + + //clear the matrix just to be sure there is nothing on it + lc.clearMatrix(); + + //count up and display the number + for (unsigned int i = 0; i<10000; i++) { + delay(500); + switchLED(); + setLEDs(i); + } + +} diff --git a/examples/german/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino b/examples/german/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino new file mode 100755 index 00000000..8513ba4e --- /dev/null +++ b/examples/german/LedControllerDemoHwSPI/LedControllerDemoHwSPI.ino @@ -0,0 +1,131 @@ +/** + * @file LedControllerDemoHwSPI.ino + * @author Noa Sakurajin (noasakurajin@web.de) + * @brief LedControllerDemoRocket.ino with hardware spi + * @version 0.1 + * @date 2020-12-30 + * + * @copyright Copyright (c) 2020 + * + */ + +#include "LedController.hpp" + +#define CS 15 +#define Segments 4 + +#define delayTime 200 // Delay between Frames + +LedController lc = LedController(); + +ByteBlock rocket= { + B00000000, + B00001111, + B00111110, + B11111101, + B00111110, + B00001111, + B00000000, + B00000000 +}; + +ByteBlock rocketColumns; + +//sets all rows on all displays to 0 +void switchLED(){ + static bool LEDON = false; + if(LEDON){ + digitalWrite(13, LOW); + }else{ + digitalWrite(13, HIGH); + } + LEDON = !LEDON; +} + +void setup(){ + lc.init(CS);// Pins: CS, # of Display connected + + lc.makeColumns(rocket, &rocketColumns); + + pinMode(13, OUTPUT); + + lc.setIntensity(0); + +} + +void loop(){ + + lc.clearMatrix(); + + //Let the rocket fly in + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveRight(rocketColumns[i]); + }else{ + lc.moveRight(); + + delay(delayTime); + switch(i % 6){ + case(3): + case(4): + case(5): + lc.moveUp(); + break; + + case(0): + case(1): + case(2): + lc.moveDown(); + break; + + default: + break; + } + } + + } + + delay(delayTime); + + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveLeft(rocketColumns[i]); + }else{ + lc.moveLeft(); + + delay(delayTime); + switch(i % 6){ + case(3): + case(4): + case(5): + lc.moveUp(); + break; + + case(0): + case(1): + case(2): + lc.moveDown(); + break; + + default: + break; + } + } + + } + + delay(delayTime); + +} diff --git a/examples/german/LedControllerDemoRocket/LedControllerDemoRocket.ino b/examples/german/LedControllerDemoRocket/LedControllerDemoRocket.ino new file mode 100755 index 00000000..f20cc5b2 --- /dev/null +++ b/examples/german/LedControllerDemoRocket/LedControllerDemoRocket.ino @@ -0,0 +1,137 @@ +/** + * @file LedControllerDemoRocket.ino + * @author Noa Sakurajin (noasakurajin@web.de) + * @brief Using the the LedController to move a rocket + * @version 0.1 + * @date 2020-12-30 + * + * @copyright Copyright (c) 2020 + * + */ + +#include "LedController.hpp" + +#define DIN 27 +#define CS 26 +#define CLK 25 + +#define Segments 4 + +#define delayTime 200 // Delay between Frames + +LedController lc = LedController(); + +ByteBlock rocket= { + B00000000, + B00001111, + B00111110, + B11111101, + B00111110, + B00001111, + B00000000, + B00000000 +}; + +ByteBlock rocketColumns; + +//sets all rows on all displays to 0 +void switchLED(){ + static bool LEDON = false; + if(LEDON){ + digitalWrite(13, LOW); + }else{ + digitalWrite(13, HIGH); + } + LEDON = !LEDON; +} + +void setup(){ + + //create a simple controller without hardware spi. + lc.init(DIN,CLK,CS); + + //make a array of columns out of the rocket + //this is needed to shift it in correctly (you can leave this line if you want to) + rocketColumns = lc.makeColumns(rocket); + + //enable the LED to have a clock + pinMode(13, OUTPUT); + +} + +void loop(){ + + lc.clearMatrix(); + + //Let the rocket fly in + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveRight(rocketColumns[i]); + }else{ + lc.moveRight(); + + delay(delayTime); + switch(i % 6){ + case(3): + case(4): + case(5): + lc.moveUp(); + break; + + case(0): + case(1): + case(2): + lc.moveDown(); + break; + + default: + break; + } + } + + } + + delay(delayTime); + + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveLeft(rocketColumns[i]); + }else{ + lc.moveLeft(); + + delay(delayTime); + switch(i % 6){ + case(3): + case(4): + case(5): + lc.moveUp(); + break; + + case(0): + case(1): + case(2): + lc.moveDown(); + break; + + default: + break; + } + } + + } + + delay(delayTime); + +} diff --git a/examples/german/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino b/examples/german/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino new file mode 100644 index 00000000..b71e97eb --- /dev/null +++ b/examples/german/LedControllerDemoRocketMulti/LedControllerDemoRocketMulti.ino @@ -0,0 +1,146 @@ +/** + * @file LedControllerDemoRocketMulti.ino + * @author Noa Sakurajin (noasakurajin@web.de) + * @brief An exaple for using multiple rows + * @version 0.1 + * @date 2020-12-30 + * + * @copyright Copyright (c) 2020 + * + */ + +#include "LedController.hpp" + +//spi pins falls nicht hardware SPI verwendet werden soll +#define DIN 27 +#define CS 16 +#define CLK 25 + +//the number of segments per row +#define Segments 4 + +//the pin number of the builtin led or an external led to signal a clock. +#define LED 13 + +#define delayTime 200 // Delay between Frames + +//creating an LedController which is not initilized. +auto lc = LedController(); + +//the pixelart of our beautiful rocket +ByteBlock rocket= { + B00000000, + B00001111, + B00111110, + B11111101, + B00111110, + B00001111, + B00000000, + B00000000 +}; + +//the rocket rotated by 180 degrees to display it properly. +ByteBlock rocketColumns; + +//switches the state of the builtin led +void switchLED(){ + static bool LEDON = false; + if(LEDON){ + digitalWrite(LED, LOW); + }else{ + digitalWrite(LED, HIGH); + } + LEDON = !LEDON; +} + +void setup(){ + + //creating the configuration of the controller + controller_configuration conf; + + //since more than one row is used make sure to set this to 0 (should be 0 but better safe than sorry) + conf.SPI_CS = 0; + + //These are the chip select pins for each row. + //The bottom row (row 0) is connected to pin 25 and the top row (row 1) is connected to pin 15 + conf.row_SPI_CS[0] = 25; + conf.row_SPI_CS[1] = 15; + + //this enables hardware spi check what pins to use for your board + conf.useHardwareSpi = true; + + //this enables debug output (nothing should be printed but it helps to fix possible problems with the config) + conf.debug_output = true; + + //since we use real multi rows this is set to false (this should not matter since SPI_CS is 0 but this is the proper way) + conf.virtual_multi_row = false; + + //this specifies the transfer speed of the spi interface. If you want to use high values make sure your cables have a good connection + conf.spiTransferSpeed = 800000; + + //initilizing the LedController with the configuration which we just set + lc.init(conf); + + //make a array of columns out of the rocket + //this is needed to shift it in correctly (you can leave this line if you want to) + rocketColumns = lc.makeColumns(rocket); + + //enables the builtin Led to have a kind of clock + pinMode(LED, OUTPUT); + +} + +void loop(){ + //clear the data to make sure the are not leftovers + lc.clearMatrix(); + + //Let the rocket fly in + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveRowRight(rocketColumns[i]); + }else{ + lc.moveRight(); + + delay(delayTime); + if(i%16 < 8){ + lc.moveDown(); + }else{ + lc.moveUp(); + } + } + + } + + delay(delayTime); + + for(int i = 0;i < 8*(Segments+1);i++){ + delay(delayTime); + + //blink led for each iteration + switchLED(); + + //if rocket not fully inside let it fly in and shift it + if(i < 8){ + lc.moveRowLeft(rocketColumns[i]); + }else{ + lc.moveLeft(); + + delay(delayTime); + if(i%16 < 8){ + lc.moveDown(); + }else{ + lc.moveUp(); + } + } + + } + + delay(delayTime); + +}