Skip to content

Commit

Permalink
added icons
Browse files Browse the repository at this point in the history
  • Loading branch information
maccoylton committed Nov 20, 2018
1 parent 2c2da51 commit 5bd65ff
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ EXTRA_COMPONENTS = \
$(abspath ../components/esp-cjson) \
$(abspath ../components/esp-homekit)

FONTS_TERMINUS_BOLD_8X14_ISO8859_1 = 1
FONTS_TERMINUS_BOLD_14X28_ISO8859_1 = 1

FLASH_SIZE ?= 8
HOMEKIT_SPI_FLASH_BASE_ADDR ?= 0x8c000

EXTRA_CFLAGS += -I../.. -DHOMEKIT_SHORT_APPLE_UUIDS -DHOMEKIT_DEBUG
EXTRA_CFLAGS += -I../.. -DHOMEKIT_SHORT_APPLE_UUIDS -DHOMEKIT_DEBUG -DFONTS_TERMINUS_BOLD_8X14_ISO8859_1 -DFONTS_TERMINUS_BOLD_14X28_ISO8859_1

include $(SDK_PATH)/common.mk

Expand Down
44 changes: 34 additions & 10 deletions src/wifi_thermostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
#include <i2c/i2c.h>
#endif

#define FONT_FACE_TERMINUS_BOLD_12X24_ISO8859_1 1
#define FONT_FACE_TERMINUS_BOLD_10X18_ISO8859_1 2

#include "fonts/fonts.h"

Expand Down Expand Up @@ -167,36 +165,62 @@ static void ssd1306_task(void *pvParameters)
ssd1306_clear_screen(&dev);

while (1) {
if (ssd1306_fill_rectangle(&dev, buffer, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, OLED_COLOR_BLACK)){
printf("Error printing rectangle\bn");
}
if (count==0){
if (ssd1306_fill_rectangle(&dev, buffer, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, OLED_COLOR_BLACK)){
printf("Error printing rectangle\bn");
}

ssd1306_load_xbm(&dev, thermostat_xbm, buffer);
if (ssd1306_load_frame_buffer(&dev, buffer))
goto error_loop;
}

sprintf(target_temp_string, "%g", (float)target_temperature.value.float_value);
sprintf(mode_string, "%i", (int)current_state.value.int_value);
switch( (int)current_state.value.int_value)
{
case 0:
sprintf(mode_string, "OFF ");
break;
case 1:
sprintf(mode_string, "HEAT");
break;
case 2:
sprintf(mode_string, "COOL");
break;
case 3:
sprintf(mode_string, "AUTO");
break;
default:
sprintf(mode_string, "? ");
}

// sprintf(mode_string, "%i", (int)current_state.value.int_value);


if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_12X24_ISO8859_1], 10, 21, target_temp_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_14X28_ISO8859_1], 5, 2, target_temp_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
printf("Error printing target temp\n");
}

if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_12X24_ISO8859_1], 10, 85, mode_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1 ){
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_14X28_ISO8859_1], 70, 2, mode_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1 ){
printf("Error printing mode\n");
}

sprintf(temperature_string, "%g", (float)current_temperature.value.float_value);
sprintf(humidity_string, "%g", (float)current_humidity.value.float_value);
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_12X24_ISO8859_1], 43, 30, temperature_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_8X14_ISO8859_1], 30, 41 , temperature_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
printf("Error printing temperature\n");
}
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_12X24_ISO8859_1], 43, 94 , humidity_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
if (ssd1306_draw_string(&dev, buffer, font_builtin_fonts[FONT_FACE_TERMINUS_BOLD_8X14_ISO8859_1], 92, 41 , humidity_string, OLED_COLOR_WHITE, OLED_COLOR_BLACK) < 1){
printf("Error printing humidity\n");
}

count ++;
if (count == 60){

count = 0;
if (ssd1306_fill_rectangle(&dev, buffer, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, OLED_COLOR_BLACK)){
printf("Error printing rectangle\bn");
}

ssd1306_clear_screen(&dev);
ssd1306_load_xbm(&dev, homekit_logo, buffer);
Expand Down
93 changes: 92 additions & 1 deletion src/wifi_thermostat.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define home_kit_logo_width 128
#define home_kit_logo_height 64
char homekit_logo[] = {
static uint8_t homekit_logo[] = {
0x00, 0x00, 0xC0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xBF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF,
Expand Down Expand Up @@ -88,3 +88,94 @@ char homekit_logo[] = {
0x00, 0x00, 0x00, 0xEA, 0xF7, 0xF7, 0xDF, 0xDF, 0xDF, 0xF7, 0x7D, 0xEF,
0x56, 0x00, 0x00, 0x00};

#define thermostat_xbm_width 128
#define thermostat_xbm_height 64
static uint8_t thermostat_xbm[] = {

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x88, 0x1F, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0xA0, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x0B, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA0, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x0F, 0x00,
0x00, 0x00, 0x00, 0x00, 0xA0, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC0, 0xFB, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x0B, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xE0, 0xE1, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA0, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x65, 0x1E, 0x00,
0x00, 0x00, 0x00, 0x00, 0xA0, 0x0B, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0x71, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x8B, 0x1E, 0x00,
0x00, 0x00, 0x00, 0x00, 0xF0, 0x1F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA0, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xDF, 0x3F, 0x00,
0x00, 0x00, 0x00, 0x00, 0xD0, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0xE7, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x17, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xF0, 0xE7, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC8, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x3B, 0x3E, 0x00,
0x00, 0x00, 0x00, 0x00, 0xE8, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xF0, 0x99, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x2F, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xE0, 0x1D, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00,
0xD8, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F, 0x0F, 0x00,
0x00, 0x00, 0x00, 0x00, 0xB0, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };

0 comments on commit 5bd65ff

Please sign in to comment.