sgjava Posted October 15, 2021 Posted October 15, 2021 Java U8g2 is a high performance library based on U8g2: Library for monochrome displays, version 2. Rather than try to code the JNI by hand I used HawtJNI to generate the JNI wrappers. I also used some custom code to generate the setup methods and font constants. final var u8g2 = U8g2.initU8g2(); // Change this to your actual display U8g2.setupSsd1306I2c128x64NonameF(u8g2, U8G2_R0, u8x8_byte_arm_linux_hw_i2c, u8x8_arm_linux_gpio_and_delay); U8g2.initDisplay(u8g2); logger.debug(String.format("Size %d x %d, draw color %d", U8g2.getDisplayWidth(u8g2), U8g2.getDisplayHeight(u8g2), U8g2. getDrawColor(u8g2))); U8g2.setPowerSave(u8g2, 0); U8g2.clearBuffer(u8g2); U8g2.setFont(u8g2, u8g2_font_t0_15b_mf); U8g2.drawStr(u8g2, 1, 18, "Java U8g2"); U8g2.sendBuffer(u8g2); try { TimeUnit.SECONDS.sleep(5); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } U8g2.setPowerSave(u8g2, 1); U8g2.done(u8g2);
Recommended Posts