Skip to content

Instantly share code, notes, and snippets.

@thegaragelab
Last active April 11, 2024 21:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thegaragelab/0a0dc5f5745a308312cf to your computer and use it in GitHub Desktop.
Save thegaragelab/0a0dc5f5745a308312cf to your computer and use it in GitHub Desktop.
Driving a Nokia 5110 LCD with the ATtiny85 Template Library

This gist provides sample code for using Nokia 5110 displays using the ATtiny85 template library. For a full description of code behind this please see this post on The Garage Lab website.

To use this sample code first clone the ATtiny85 template repository and then replace 'main.c' with the source provided here.

/*--------------------------------------------------------------------------*
* Main program
*---------------------------------------------------------------------------*
* 14-Apr-2014 ShaneG
*
* Template program for ATtiny85 C/asm projects.
*--------------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "softuart.h"
#include "utility.h"
#include "nokialcd.h"
// Forward declaration with 'noreturn' attribute
void main() __attribute__ ((noreturn));
const uint8_t IMAGE_TGL_LOGO[] PROGMEM = {
0xeb, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0xe0, 0x60, 0x60,
0x30, 0x30, 0x38, 0x18, 0x18, 0x0c, 0x0c, 0x0e, 0x06, 0x06, 0x03, 0x03,
0x03, 0x03, 0x06, 0x06, 0x0e, 0x0c, 0x1c, 0x18, 0x18, 0x30, 0x30, 0x60,
0x60, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x06, 0x03, 0x03,
0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf8, 0x08, 0x48, 0x48, 0x48, 0x48,
0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48,
0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x08, 0xf8, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0x03, 0x03, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x00, 0x00, 0xff, 0x00, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92,
0x92, 0x92, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x00, 0x40, 0xe0, 0xe0, 0xff, 0xff, 0xe0, 0xe0, 0xe0, 0xe0, 0xff, 0xe0,
0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4,
0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe4, 0xe0, 0xff,
0xe0, 0xe0, 0xe0, 0xe0, 0xff, 0xff, 0xe0, 0xe0, 0x40,
};
/** Program entry point
*/
void main() {
lcdInit();
lcdClear(false);
// Display the logo
lcdImageP(0, 20, IMAGE_TGL_LOGO, false);
lcdPrint(5, 0, "The Garage Lab", false);
// Block forever
while(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment