Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <asf.h>
- #include "u8g.h"
- #include <string.h>
- u8g_t LCD;
- uint32_t sxpos = 0;
- uint16_t clockminutes = 0;
- char watchstring[7];
- //unsigned char str_out[9];
- //unsigned char xbuffer[3];
- void draw(void)
- {
- itoa(clockminutes,watchstring,10);
- u8g_SetColorIndex(&LCD, 1);
- //u8g_DrawBox(&LCD, 0, 0, 84, 48);
- //u8g_DrawFrame(&LCD, 0, 0, 84, 48);
- u8g_SetFont(&LCD, u8g_font_9x15);
- u8g_DrawStr(&LCD, 0, 0, watchstring);
- u8g_DrawStr(&LCD, 0, 25, "lol");
- }
- int main(void)
- {
- /* select minimal prescaler (max system speed) */
- CLKPR = 0x80;
- CLKPR = 0x00;
- /*
- uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, SCK, mosi, Chip select, Register select, Reset);
- u8g_dev_pcd8544_84x48_hw_spi
- för SW måste du flytta på mosi till miso.
- */
- u8g_InitSPI(&LCD, &u8g_dev_pcd8544_84x48_hw_spi, PN(1, 7), PN(1, 6), PN(1, 2), PN(1, 3), PN(1, 1));
- u8g_SetRot180(&LCD);
- // enable bit 5 "ASSR". enables external crystal
- //ASSR |= (1<<6);
- ASSR |= (1<<5);
- u8g_Delay(250); //let external 32KHz crystal stabilize
- TCCR2B |= ((1 << WGM22));
- TIMSK2 |= (1 << OCIE2A); // Enable CTC interrupt
- sei();
- OCR2A = 1;
- TCCR2B |= (1 << CS22) | (1 << CS20); // 32.768kHz / 128 = 1Hz overflow
- DDRA |= (1 << 0);
- for(;;)
- {
- //memset(str_out, 0, 9); töm array
- //strcat(str_out, "pwm: ");
- //itoa(sxpos, xbuffer, 10);
- //strcat(str_out, xbuffer);
- u8g_FirstPage(&LCD);
- do
- {
- draw();
- } while ( u8g_NextPage(&LCD) );
- u8g_Delay(800); //~1fps
- }
- }
- ISR(TIMER2_COMPA_vect)
- {
- PORTA ^= (1 << 0); // Toggle the LED
- clockminutes++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement