bzyx / 6 lat temu | Download | Plaintext | Odpowiedz |

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* 
Based on dogm128 libary file atmega88/fonts/fonts.c
*/
#include <stdlib.h>
#include "dogm128.h"

extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;

void system_init(void)
{
#if defined(__AVR__)
  /* select minimal prescaler (max system speed) */
  CLKPR = 0x80;
  CLKPR = 0x00;
#endif
}

int freeMemory() {
  int free_memory;

  if((int)__brkval == 0)
     free_memory = ((int)&free_memory) - ((int)&__bss_end);
  else
    free_memory = ((int)&free_memory) - ((int)__brkval);

  return free_memory;
}

char txt[10];
void loop(void) {
  unsigned char h =9;
  dog_StartPage();
  do {
  	int mem = freeMemory();
  	itoa(mem, txt, 10);
	dog_DrawStrP(0,h*0+3, font_5x8, DOG_PSTR("http://bzyx.jogger.pl"));
	dog_DrawStr(110,h*0+3, font_4x6, txt);
	dog_DrawStrP(0,h*1+3, font_5x8, DOG_PSTR("marcin.jabrzyk@gmail.com"));
	dog_DrawStrP(0,h*2+3, font_5x8, DOG_PSTR("XMPP:bzyx@jabster.pl"));
	dog_DrawStrP(0,h*3+3, font_5x8, DOG_PSTR("SMiW projekt 2011"));
	dog_DrawStrP(0,h*5+3, font_9x18, DOG_PSTR("Marcin Jabrzyk"));
  } while( dog_NextPage() );
  dog_Delay(100);
}


int main(void)
{
  system_init();
  dog_Init(0);
  dog_SetContrast(10);
  dog_Delay(120);
  for(;;)
  {
    loop();
  }
}