01-08-2015, 01:25 AM
I've created another watchface. It shows the time and date for your present timezone, plus three other hardwired zones.
It also does flashcards for learning Japanese. It shows a bitmap for a character and then a few seconds later, it shows the pronunciation and meaning.
you need to change the watchface in main to this:
display_set(watchface_zoneflash);
this is the zoneflash.c file, which goes in the watchfaces folder.
Add this to your common.h file:
#include "watchfaces/zoneflash.h"
create a zoneflash.h file in the include/watchfaces folder.
The final bit is the bitmaps for the characters and the pronunciation and English translation. This goes into includes/watchfaces/flash.h
It also does flashcards for learning Japanese. It shows a bitmap for a character and then a few seconds later, it shows the pronunciation and meaning.
you need to change the watchface in main to this:
display_set(watchface_zoneflash);
this is the zoneflash.c file, which goes in the watchfaces folder.
Code:
#include "common.h"
#include "watchfaces/flash.h"
static void drawDate(void);
static void drawFlash(void);
static void drawTimeZones(void);
static display_t draw(void);
static byte secs;
static char extra1,extra2, extra3;
static int newtime1, newtime2, newtime3;
void watchface_zoneflash()
{
display_setDrawFunc(draw);
buttons_setFuncs(NULL, menu_select, NULL);
}
static display_t draw()
{
drawDate();
draw_string("JP", false, 0, 10);
draw_string(time_timeStr(), false, 21, 10);
// Draw battery icon
drawBattery();
drawTimeZones();
drawFlash();
return DISPLAY_DONE;
}
static void drawTimeZones()
{
char buff[6];
// if (timeDate.time.secs == 0){
extra1 = ' ';
newtime1 = timeDate.time.hour-9;
if (newtime1 < 0){
newtime1 = 24+newtime1;
extra1 = '-';
}
newtime2 = timeDate.time.hour-14;
extra2 = ' ';
if (newtime2 < 0){
newtime2 = 24+newtime2;
extra2 = '-';
}
newtime3 = timeDate.time.hour-17;
extra3 = ' ';
if (newtime3 < 0){
newtime3 = 24+newtime3;
extra3 = '-';
}
//}
sprintf_P(buff, PSTR("%2s %02hhu%c"), "UK",newtime1,extra1);
draw_string(buff, false, 0, 20);
sprintf_P(buff, PSTR("%2s %02hhu%c"), "NY",newtime2,extra2);
draw_string(buff, false, 0, 30);
sprintf_P(buff, PSTR("%2s %02hhu%c"), "CA",newtime3,extra3);
draw_string(buff, false, 0, 40);
}
static void drawFlash()
{
static byte jinum;
byte modval = 6;
if(timeDate.time.secs % modval == 0 && timeDate.time.secs != secs)
{
jinum = rand() % NUMLEX;
}
if (timeDate.time.secs % modval > 3)
{
draw_string(translation[jinum], false, 50, 20);
draw_string(romanji[jinum], false, 50, 30);
}
image_s img = newImage(50,40, &ji[147*jinum], 25*2-1, 24, WHITE, NOINVERT, 0);
draw_bitmap_set(&img);
draw_bitmap_s2(&img);
secs = timeDate.time.secs;
}
static void drawDate()
{
// Get day string
char day[BUFFSIZE_STR_DAYS];
strcpy_P(day, days[timeDate.date.day]);
// Get month string
char month[BUFFSIZE_STR_MONTHS];
strcpy_P(month, months[timeDate.date.month]);
// Draw date
char buff[BUFFSIZE_DATE_FORMAT];
sprintf_P(buff, PSTR(DATE_FORMAT), day, timeDate.date.date, month, timeDate.date.year);
draw_string(buff,false,12,0);
}
Add this to your common.h file:
#include "watchfaces/zoneflash.h"
create a zoneflash.h file in the include/watchfaces folder.
Code:
#ifndef ZONE_H_
#define ZONE_H_
void watchface_zoneflash(void);
#endif /* ZONE_H_ */
The final bit is the bitmaps for the characters and the pronunciation and English translation. This goes into includes/watchfaces/flash.h
Code:
// Japanese flash cards
// ji has the bitmaps for the kanji
//
static const byte ji[] PROGMEM ={
0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x70,0xF0,0x90,0x10,0x1C,0x1C,0x10,0x10,0xF0,0xF0,0x30,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0x83,0xE3,0xF3,0x7B,0x7B,0x63,0x63,0x63,0xFB,0xFB,0x63,0x63,0x63,0x63,0x63,0x63,0x03,0x00,0x00,0x00,0x00,0x00,0xC0,0xCF,0x0F,0x0C,0x0C,0x0C,0x0C,0x0C,0xFF,0xFF,0x0C,0x0C,0x0C,0x0C,0x0C,0x0F,0x0F,0xC0,0xC0,0x00,0x00,
0x00,0x00,0x30,0x7F,0x1F,0x00,0x20,0x21,0x20,0x22,0x22,0x22,0x22,0x22,0x3F,0x3F,0x22,0x22,0x22,0x22,0x22,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x30,0x30,0x30,0x30,0x30,0x30,0x3F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x7F,0x7F,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0xF0,0xFC,0x7C,0x40,0xC0,0xC0,0x00,0x00,0x00,0xF8,0xF8,0x18,0x18,0xF8,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0xF0,0xF0,0x30,0x10,0x10,0x00,0xF8,0xF8,0x88,0x88,0x98,0xF8,0x98,0x88,0x88,0xF8,0xF8,0x00,0x00,0x00,
0x00,0x00,0x30,0x3C,0x0F,0x1F,0xFE,0xC0,0xE0,0xFF,0x1F,0x00,0xC0,0xF0,0x7F,0x03,0x00,0x00,0xFF,0xFF,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x04,0x04,0xFF,0xFF,0x0E,0x04,0x04,0x00,0x1F,0x1F,0x11,0x11,0x39,0xFF,0xB9,0x11,0x11,0x1F,0x1F,0x00,0x00,0x00,
0x00,0x00,0x20,0x70,0x38,0x1C,0x0E,0x07,0x07,0x0E,0x1C,0x19,0x33,0x31,0x30,0x60,0x60,0x60,0x61,0x63,0x63,0x63,0x63,0x00,0x00,0x00,0x04,0x0E,0x06,0x07,0x07,0x03,0x03,0x23,0x20,0x23,0x23,0x23,0x23,0x33,0x3F,0x33,0x23,0x23,0x23,0x23,0x20,0x00,0x00,
0x00,0x00,0x00,0x0C,0x2C,0x6C,0x4C,0x0C,0x0C,0x8C,0xFC,0xFC,0x00,0x00,0x2C,0x6C,0x4C,0x0C,0x0C,0x8C,0x0C,0xFC,0xF8,0x00,0x00,0x00,0x20,0x60,0x70,0x38,0x1C,0x8C,0x00,0x00,0xF8,0xFC,0x6C,0x4C,0x4C,0x4C,0x4C,0x4C,0x4C,0xFC,0xFC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x06,0xE6,0xE3,0xE3,0x61,0x69,0x6F,0x6F,0x70,0x72,0x66,0x62,0x63,0x63,0xE1,0xE1,0xEC,0x0F,0x07,0x00,0x00,0x00,0x20,0x70,0x38,0xFC,0xFF,0x03,0x81,0x90,0x93,0x93,0x93,0x92,0x92,0x92,0x92,0x92,0xF2,0xF3,0xF3,0x90,0x90,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x76,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x76,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,0x00,0x06,0x0C,0x0C,0x00,0x00,0x20,0x60,0x7F,0x3F,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0xC8,0xC8,0x88,0x88,0x88,0xC8,0xC8,0xF8,0x78,0x38,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0xF8,0x98,0x88,0x88,0xF8,0xF8,0x00,0x00,0xF0,0xF0,0x00,0x00,0xFC,0xFC,0x00,0x00,
0x00,0x00,0x08,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0D,0xFF,0xFF,0x0F,0x0C,0x0C,0x8C,0xCC,0xEC,0x7C,0x3C,0x1C,0x08,0x00,0x00,0x00,0x03,0x06,0x86,0x80,0x00,0x00,0xFF,0x19,0x19,0x19,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x7F,0x7F,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x3E,0x07,0x01,0x20,0x30,0x1D,0x09,0x01,0x01,0x09,0x39,0x30,0x00,0x01,0x01,0x60,0x60,0x3F,0x1F,0x00,0x00,
0x00,0x00,0x00,0xC0,0xC0,0xC4,0xDC,0xD8,0xC0,0xC0,0xC0,0xCC,0xDC,0xD8,0xC0,0xC0,0xC0,0xF0,0xFC,0xDC,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x0C,0x2C,0x6C,0x4C,0x0C,0x0C,0x8C,0xFC,0xFC,0x00,0x00,0x2C,0x6C,0x4C,0x0C,0x0C,0x8C,0x0C,0xFC,0xF8,0x00,0x00,
0x00,0x00,0x00,0x87,0x87,0x80,0x84,0x84,0x84,0x84,0x84,0x84,0xE4,0xE4,0xB4,0xBC,0x9C,0x8C,0x8C,0x80,0x80,0x87,0x87,0x00,0x00,0x00,0x00,0x06,0x06,0xE6,0xE3,0xE3,0x61,0x69,0x6F,0x6F,0x70,0x72,0x66,0x62,0x63,0x63,0xE1,0xE1,0xEC,0x0F,0x07,0x00,0x00,
0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x21,0x61,0x61,0x3F,0x3F,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x76,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x76,0x7F,0x7F,0x00,0x00,0x00,0x00,
};
#define NUMLEX 5
static char translation[][15] = {"production","processing","acquisition","prediction","learning"};
static char romanji[][15] = {"sanshutsu","shori","shuutoku", "yosoku","gakushuu"};