Advertisement
nirach

Lawgiver code

Jun 25th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. #include <FastLED.h>
  2. #include <Arduino.h>
  3. #include <U8g2lib.h>
  4.  
  5. #define LED_PIN 2
  6. #define NUM_LEDS 1
  7. #define BRIGHTNESS 5
  8. #define LED_TYPE WS2812
  9. CRGB leds[NUM_LEDS];
  10. int lbar=1;
  11. boolean idcheck = true;
  12. unsigned long startMillis;
  13. unsigned long currentMillis;
  14. const unsigned long period=4500;
  15.  
  16. U8G2_SSD1305_128X32_NONAME_F_4W_SW_SPI u8g2(U8G2_R0, 10, 9, 12, 11, 13);
  17.  
  18. void setup(void)
  19. {
  20. u8g2.begin();
  21. FastLED.addLeds<LED_TYPE, LED_PIN>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  22. FastLED.setBrightness(BRIGHTNESS );
  23. startMillis = millis();
  24. }
  25.  
  26. void loop(void)
  27. {
  28. currentMillis = millis();
  29. u8g2.clearBuffer();
  30. //ID Check bar
  31. if (idcheck == true)
  32. {
  33. lbar++;
  34. if (lbar >100) lbar=0, boolean (idcheck=false);
  35. delay(5);
  36. u8g2.drawBox (1,1,lbar,6);
  37. }
  38.  
  39. // ID Check LED
  40. if (idcheck == true)
  41. {
  42. leds[0] = CRGB(0,255,0);
  43. FastLED.show();
  44. }
  45. if (idcheck == false)
  46. {
  47. leds[0] = CRGB(255,0,0);
  48. FastLED.show();
  49. }
  50.  
  51. //Text-noninverse
  52.  
  53. u8g2.setFont(u8g2_font_artossans8_8u);
  54. u8g2.setCursor(2,22);
  55. if (idcheck == true)
  56. {
  57. u8g2.print("DNA CHECK");
  58. }
  59.  
  60. else if (currentMillis - startMillis <= period && idcheck == false)
  61. {
  62. u8g2.print("I.D OK");
  63. }
  64.  
  65. u8g2.setFont(u8g2_font_profont10_tf);
  66. u8g2.setCursor(104,22);
  67. u8g2.print("RAPID");
  68.  
  69. //NUMBERS
  70. u8g2.setFont(u8g2_font_4x6_tr);
  71. //DISTANCE-NUM
  72. u8g2.setCursor(9,32);
  73. u8g2.print("0.0");
  74. //AP-NUM
  75. u8g2.setCursor(23,32);
  76. u8g2.print("25");
  77. //IN-NUM
  78. u8g2.setCursor(48,32);
  79. u8g2.print("25");
  80. //HE-NUM
  81. u8g2.setCursor(79,32);
  82. u8g2.print("25");
  83. //FMJ-NUM
  84. u8g2.setCursor(102,32);
  85. u8g2.print("25");
  86.  
  87. //TEXT
  88. //Distance-TEXT
  89. u8g2.setCursor(2,32);
  90. u8g2.print("D:");
  91. //AP-TEXT
  92. u8g2.setCursor(32,32);
  93. u8g2.print("ap");
  94. //IN-TEXT
  95. u8g2.setCursor(57,32);
  96. u8g2.print("in");
  97. //HE-TEXT
  98. u8g2.setCursor(89,32);
  99. u8g2.print("he");
  100. //FMJ-TEXT
  101. u8g2.setCursor(111,32);
  102. u8g2.print("fmj");
  103.  
  104.  
  105. //Linedrawings
  106. //horizontal and vertical lines bottom
  107. u8g2.drawLine(1,25,127,25);
  108. u8g2.drawLine(21,31,21,25);
  109. u8g2.drawLine(46,31,46,25);
  110. u8g2.drawLine(77,31,77,25);
  111. u8g2.drawLine(100,31,100,25);
  112. //angled lines top right
  113. u8g2.drawLine(121,1,120,6);
  114. u8g2.drawLine(123,1,122,6);
  115. u8g2.drawLine(125,1,124,6);
  116. u8g2.drawLine(127,1,126,6);
  117.  
  118. u8g2.sendBuffer();
  119. delay(5);
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement