private void InitializePeripherals() { speaker = new PiezoSpeaker(N.PWMChannels.PWM_PIN_D3); buttonLeft = new PushButton(N.Pins.GPIO_PIN_D2, CircuitTerminationType.CommonGround); buttonRight = new PushButton(N.Pins.GPIO_PIN_D5, CircuitTerminationType.CommonGround); buttonLeft.Clicked += ButtonLeft_Clicked; buttonRight.Clicked += ButtonRight_Clicked; display = new ILI9163(chipSelectPin: N.Pins.GPIO_PIN_D4, dcPin: N.Pins.GPIO_PIN_D7, resetPin: N.Pins.GPIO_PIN_D6, spiModule: SPI.SPI_module.SPI1, speedKHz: 15000); graphics = new GraphicsLibrary(display); }
public MeadowApp() { Console.WriteLine("Initializing..."); var spiBus = Device.CreateSpiBus(); display = new ILI9163 ( device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 128, height: 160 ); graphics = new GraphicsLibrary(display); TestILI9163(); }
static void DrawBitmap(int x, int y, byte[] data, ILI9163 display) { byte r, g, b; int offset = 14 + data[14]; int width = data[18]; int height = data[22]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { b = data[i * 3 + j * width * 3 + offset]; g = data[i * 3 + j * width * 3 + offset + 1]; r = data[i * 3 + j * width * 3 + offset + 2]; display.DrawPixel(x + i, y + height - j, r, g, b); } } }
static void DitherTest(ILI9163 tft) { var bytes = Resources.GetBytes(Resources.BinaryResources.meadow); int width = bytes[18]; int height = bytes[22]; DrawBitmap(5, 65, bytes, tft); bytes = NFBitmap.Get8bppGreyScale(bytes); Draw8bppGrayscaleBitmap(5, 110, bytes, width, height, tft); bytes = NFBitmap.Dither8bppto1bpp(bytes, width, height, true); Draw8bppGrayscaleBitmap(5, 155, bytes, width, height, tft); tft.Refresh(); Thread.Sleep(1000); display.CurrentFont = new Font8x12(); display.DrawText(5, 5, "Dither test", Color.White); display.Show(); Thread.Sleep(Timeout.Infinite); }
public static void Main() { tft = new ILI9163(chipSelectPin: Pins.GPIO_PIN_D4, dcPin: Pins.GPIO_PIN_D7, resetPin: Pins.GPIO_PIN_D6, width: 128, height: 160, spiModule: SPI.SPI_module.SPI1, speedKHz: 15000); tft.ClearScreen(31); tft.Refresh(); display = new GraphicsLibrary(tft); led = new Led(Pins.ONBOARD_LED); button = new PushButton(Pins.ONBOARD_BTN, CircuitTerminationType.CommonGround); button.Clicked += Button_Clicked; UITest(); //DitherTest(tft); Thread.Sleep(-1); }
static void InitDisplays() { tftDisplay = new ILI9163(chipSelectPin: Pins.GPIO_PIN_D4, dcPin: Pins.GPIO_PIN_D7, resetPin: Pins.GPIO_PIN_D6, width: 128, height: 160, spiModule: SPI.SPI_module.SPI1, speedKHz: 25000); oledDisplay = new SSD1306(0x3C, 400, SSD1306.DisplayType.OLED128x32); font4x8 = new Font4x8(); font8x12 = new Font8x12(); tftGraphics = new GraphicsLibrary(tftDisplay) { CurrentFont = font4x8 }; oledGraphics = new GraphicsLibrary(oledDisplay) { CurrentFont = font8x12 }; }
static void Draw8bppGrayscaleBitmap(int x, int y, byte[] data, int width, int height, ILI9163 display) { byte c; //test by drawing to screen for (int j = 0; j < height; j++) { for (int k = 0; k < width; k++) { c = data[k + j * width]; display.DrawPixel(x + k, y + height - j, c, c, c); } } }