avr-something

Something something AVR side…
git clone git://henryandlizzy.uk/avr-something
Log | Files | Refs | README

lcd.h (1164B)


      1 #pragma once
      2 
      3 #include "io.h"
      4 #include "hidModule.h"
      5 
      6 #include <util/delay.h>
      7 
      8 /*
      9 	A0~ chip select
     10 	A1  Backlight
     11 	A2~ Reset
     12 	A3~ Write
     13 	A4~ Command
     14 	A5~ Read
     15 	A6~ Vsync
     16 	A7~ Hsync
     17 
     18 	C[0-7] DATA BUS
     19 */
     20 namespace lcd {
     21 
     22 constexpr auto n_select = ~bit(0);
     23 constexpr auto backlight = bit(1);
     24 constexpr auto n_reset = ~bit(2);
     25 constexpr auto n_write = ~bit(3);
     26 constexpr auto n_command = ~bit(4);
     27 constexpr auto n_read = ~bit(5);
     28 constexpr auto n_vsync = ~bit(6);
     29 constexpr auto n_hsync = ~bit(7);
     30 
     31 constexpr auto defaultControl = n_select;
     32 
     33 inline constexpr auto& control()
     34 {
     35 	return io::out::A();
     36 }
     37 inline constexpr auto& data()
     38 {
     39 	return io::out::C();
     40 }
     41 inline constexpr auto& controlDir()
     42 {
     43 	return io::direction::A();
     44 }
     45 inline constexpr auto& dataDir()
     46 {
     47 	return io::direction::C();
     48 }
     49 
     50 constexpr uint16_t red   = 0xF800;
     51 constexpr uint16_t green = 0x07E0;
     52 constexpr uint16_t blue  = 0x001F;
     53 
     54 constexpr uint16_t black = 0;
     55 constexpr uint16_t dgrey = 0x18E5;
     56 constexpr uint16_t grey  = 0x39E7;
     57 constexpr uint16_t white = 0xFFFF;
     58 
     59 static_assert(red + green + blue == white, "RGB masks sum incorrectly");
     60 
     61 void init();
     62 
     63 [[noreturn]]
     64 void test();
     65 
     66 void testFont();
     67 
     68 }