main.c 973 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. main.c
  3. hello world example for raspberry pi
  4. For speedup run this example as root, either wis
  5. sudo ./main
  6. or by setting the superuser bit:
  7. sudo chown root:root ./main
  8. sudo chmod u+s ./main
  9. */
  10. #include "raspi_gpio_hal.h"
  11. #include "u8g2.h"
  12. int main(void)
  13. {
  14. u8g2_t u8g2; // a structure which will contain all the data for one display
  15. u8g2_Setup_sh1107_i2c_seeed_128x128_f(&u8g2, U8G2_R0, u8x8_byte_sw_i2c, u8x8_gpio_and_delay_raspi_gpio_hal); // init u8g2 structure
  16. u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_CLOCK, 5);
  17. u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_I2C_DATA, 6);
  18. u8g2_InitDisplay(&u8g2); // send init sequence to the display, display is in sleep mode after this,
  19. u8g2_SetPowerSave(&u8g2, 0); // wake up display
  20. u8g2_ClearBuffer(&u8g2);
  21. u8g2_SendBuffer(&u8g2);
  22. u8g2_SetFont(&u8g2, u8g2_font_helvB24_tr);
  23. u8g2_DrawStr(&u8g2, 0, 50, "Hello");
  24. u8g2_DrawStr(&u8g2, 0, 100, "World!");
  25. u8g2_SendBuffer(&u8g2);
  26. }