Skip to content

Commit

Permalink
preparations for multilingual examples
Browse files Browse the repository at this point in the history
  • Loading branch information
noah1510 committed Jan 24, 2021
1 parent 8c2700b commit 4914d22
Show file tree
Hide file tree
Showing 11 changed files with 683 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .scripts/doxygen_multilang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
File renamed without changes.
93 changes: 93 additions & 0 deletions examples/german/LCDemo7Segment/LCDemo7Segment.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* @file LCDemo7Segment.ino
* @author Noa Sakurajin ([email protected])
* @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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/**
* @file LedControllerDemoCounting.ino
* @author Noa Sakurajin ([email protected])
* @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<Segments,1> 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<Segments,1>(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);
}

}
Loading

0 comments on commit 4914d22

Please sign in to comment.