Java U8g2
#1
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 HawtJNI methods and font constants. This makes life easier going forawrd as changes are simple to keep in sync.

Code:
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);
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Java Periphery with JDK 17 support sgjava 0 183 10-08-2021, 08:09 AM
Last Post: sgjava

Forum Jump:


Users browsing this thread: 1 Guest(s)