Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include <Arduino.h>
- #include <U8g2lib.h>
- #define LED_PIN 2
- #define NUM_LEDS 1
- #define BRIGHTNESS 5
- #define LED_TYPE WS2812
- CRGB leds[NUM_LEDS];
- int lbar=1;
- boolean idcheck = true;
- unsigned long startMillis;
- unsigned long currentMillis;
- const unsigned long period=4500;
- U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, 10, 9, 12, 11, 13);
- void setup(void)
- {
- u8g2.begin();
- FastLED.addLeds<LED_TYPE, LED_PIN>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness(BRIGHTNESS );
- startMillis = millis();
- }
- void loop(void)
- {
- currentMillis = millis();
- u8g2.clearBuffer();
- //ID Check bar
- if (idcheck == true)
- {
- lbar++;
- if (lbar >100) lbar=0, boolean (idcheck=false);
- delay(5);
- u8g2.drawBox (1,1,lbar,6);
- }
- // ID Check LED
- if (idcheck == true)
- {
- leds[0] = CRGB(0,255,0);
- FastLED.show();
- }
- if (idcheck == false)
- {
- leds[0] = CRGB(255,0,0);
- FastLED.show();
- }
- //Text-noninverse
- u8g2.setFont(u8g2_font_artossans8_8u);
- u8g2.setCursor(2,22);
- if (idcheck == true)
- {
- u8g2.print("DNA CHECK");
- }
- else if (currentMillis - startMillis <= period && idcheck == false)
- {
- u8g2.print("I.D OK");
- }
- u8g2.setFont(u8g2_font_profont10_tf);
- u8g2.setCursor(104,22);
- u8g2.print("RAPID");
- //NUMBERS
- u8g2.setFont(u8g2_font_4x6_tr);
- //DISTANCE-NUM
- u8g2.setCursor(9,32);
- u8g2.print("0.0");
- //AP-NUM
- u8g2.setCursor(23,32);
- u8g2.print("25");
- //IN-NUM
- u8g2.setCursor(48,32);
- u8g2.print("25");
- //HE-NUM
- u8g2.setCursor(79,32);
- u8g2.print("25");
- //FMJ-NUM
- u8g2.setCursor(102,32);
- u8g2.print("25");
- //TEXT
- //Distance-TEXT
- u8g2.setCursor(2,32);
- u8g2.print("D:");
- //AP-TEXT
- u8g2.setCursor(32,32);
- u8g2.print("ap");
- //IN-TEXT
- u8g2.setCursor(57,32);
- u8g2.print("in");
- //HE-TEXT
- u8g2.setCursor(89,32);
- u8g2.print("he");
- //FMJ-TEXT
- u8g2.setCursor(111,32);
- u8g2.print("fmj");
- //Linedrawings
- //horizontal and vertical lines bottom
- u8g2.drawLine(1,25,127,25);
- u8g2.drawLine(21,31,21,25);
- u8g2.drawLine(46,31,46,25);
- u8g2.drawLine(77,31,77,25);
- u8g2.drawLine(100,31,100,25);
- //angled lines top right
- u8g2.drawLine(121,1,120,6);
- u8g2.drawLine(123,1,122,6);
- u8g2.drawLine(125,1,124,6);
- u8g2.drawLine(127,1,126,6);
- u8g2.sendBuffer();
- delay(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement