| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
@ -0,0 +1,56 @@ | 
				
			||||
use std::fs; | 
				
			||||
use std::process::Command; | 
				
			||||
use std::string::ToString; | 
				
			||||
 | 
				
			||||
fn main() { | 
				
			||||
    for entry in fs::read_dir(".").unwrap() { | 
				
			||||
        let entry = entry.unwrap(); | 
				
			||||
        let path = entry.path(); | 
				
			||||
        
 | 
				
			||||
        if !path.display().to_string().ends_with(".ico") { | 
				
			||||
            continue; | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        let name = path.file_stem().unwrap().to_str().unwrap(); | 
				
			||||
        
 | 
				
			||||
        Command::new("/bin/convert").arg(&path).arg("./tmp.xbm").output().unwrap(); | 
				
			||||
        
 | 
				
			||||
        let content = fs::read_to_string("./tmp.xbm").unwrap(); | 
				
			||||
        
 | 
				
			||||
        let a = content.find('{').unwrap() + 1; | 
				
			||||
        let b = content.find('}').unwrap(); | 
				
			||||
        
 | 
				
			||||
        let bytes = &content[a..b].trim(); | 
				
			||||
        
 | 
				
			||||
        let bytes = bytes.split(",") | 
				
			||||
            .map(|s| s.trim()) | 
				
			||||
            .filter(|s| !s.is_empty()) | 
				
			||||
            .map(|s| u8::from_str_radix(&s[2..], 16).unwrap()) | 
				
			||||
            .collect::<Vec<_>>(); | 
				
			||||
        
 | 
				
			||||
        assert!(bytes.len() == 8); | 
				
			||||
        
 | 
				
			||||
        let mut columns : [u8; 5] = [0,0,0,0,0]; | 
				
			||||
        
 | 
				
			||||
        for (n, r) in bytes.iter().enumerate() { | 
				
			||||
          for i in 0..5 { | 
				
			||||
            if 0 != *r & (1<<i) { | 
				
			||||
              columns[i] |= 1 << n; | 
				
			||||
            } | 
				
			||||
          } 
 | 
				
			||||
        }        
 | 
				
			||||
        
 | 
				
			||||
        fn testchar(c : char) -> bool { | 
				
			||||
          c.is_alphanumeric() || c=='_' | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        let mut name = name.replace(|c:char|!testchar(c), "_"); | 
				
			||||
        if !name.starts_with(testchar) { | 
				
			||||
          name = format!("_{}", name); | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        println!("const uint8_t {}[5] = {{ {} }};", name, columns.iter().map(|c| format!("{:#04x}", !c)).collect::<Vec<_>>().join(", ")); | 
				
			||||
    } | 
				
			||||
    
 | 
				
			||||
    let _ = fs::remove_file("./tmp.xbm"); | 
				
			||||
} | 
				
			||||
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
@ -0,0 +1,71 @@ | 
				
			||||
#include "bitmaps.h" | 
				
			||||
#include <stddef.h> | 
				
			||||
#include <string.h> | 
				
			||||
 | 
				
			||||
 | 
				
			||||
/* 84x48: boot_logo */ | 
				
			||||
// ····················································································
 | 
				
			||||
// ·····································································████████·······
 | 
				
			||||
// ························································█████████████····█···██·····
 | 
				
			||||
// ···················█·······························█████····█·███·····███······█····
 | 
				
			||||
// ······█·█····································██████···██·█████··███████·········█···
 | 
				
			||||
// ·······█······························███████····██·█████·█·······███··········█····
 | 
				
			||||
// ······█·█······················███████·····███·███████··██···················██·····
 | 
				
			||||
// ···························██████·██·███·███·███████████·████·············███·······
 | 
				
			||||
// ······················████████████·██··███··█████████·█████·············██·██·······
 | 
				
			||||
// ··················█████·██·████···█·████···███████·███·············█████···██·······
 | 
				
			||||
// ·············███████████·█████████████···██·······█············█████··█·█·█·██······
 | 
				
			||||
// ············██████████·██████████··███████·················█████··█·██·█···███······
 | 
				
			||||
// ·········██████··█··████·██·███···████·█···············████···█··███··█······██·····
 | 
				
			||||
// ······███·████████████████████··██················█████··█···█·█·█···········█·█····
 | 
				
			||||
// ···███████····················██··············████·█····█·····█················█····
 | 
				
			||||
// ····██··························█·············█···█····██······················█····
 | 
				
			||||
// ··██·····························█·······█·█·█···█····██·······················█····
 | 
				
			||||
// ·█······························█·······█·█·█···█·█····························█····
 | 
				
			||||
// ·█····························██·······█·█·█·····█····················█········█····
 | 
				
			||||
// ··██······················████·█·█·█··█·······························█······█··█···
 | 
				
			||||
// ····████···················█··█·█·█··█································█······█··█···
 | 
				
			||||
// ·······█···················██·█·██··························█·········█······█··█···
 | 
				
			||||
// ·······█····················█·██······█·····················█··········█·····█··█···
 | 
				
			||||
// ·······█····················█·█········█··········█··········█·········█·····███····
 | 
				
			||||
// ········█···················█··········█···········█·········█·····██████████·······
 | 
				
			||||
// ········█····················█·········█············█·········█·███·················
 | 
				
			||||
// ········█····················█··········█···········█·······████····················
 | 
				
			||||
// ········█·····················█·········█············█·█████························
 | 
				
			||||
// ········█······················█·········█·········████·····························
 | 
				
			||||
// ········█·······················█········█····█████···██················█·█·········
 | 
				
			||||
// ·········█······················█·········█·██···························█··········
 | 
				
			||||
// ·········█······················█·······████····························█·█·········
 | 
				
			||||
// ·········█······················█····███·····················█······················
 | 
				
			||||
// ·········█·······················████·······················███·····················
 | 
				
			||||
// ·········█·····················███···························█······················
 | 
				
			||||
// ·········█········██████████████····················································
 | 
				
			||||
// ··········█·██████·····························································█····
 | 
				
			||||
// ···········█····························································█······█····
 | 
				
			||||
// ··························································█············█·······█····
 | 
				
			||||
// ··████·································█··················█······██····█··█····█····
 | 
				
			||||
// ··█···█···██████···█████████····█·····███████···███████···█·····█··█····█·██····█···
 | 
				
			||||
// ··█···█··██·····█·█·█··········█·█······█····█·█·█·······█·····█····█···█··█····█···
 | 
				
			||||
// ··████····█·····██··█··········█·█······█····█···██████··█·····█····█···█··█····█···
 | 
				
			||||
// ··█···█···██████··███████·····█···█·····█···█··███·······█·····█···█·····█·██···█···
 | 
				
			||||
// ··█····█··██········█········███████····█··█·····█·······█······█·█······█·█·█·█····
 | 
				
			||||
// ··█···█···█·██······█·····██··█····█··█████······█········█████··█········█···█·····
 | 
				
			||||
// ██████····█···███····█████···█·····██············█··································
 | 
				
			||||
// ··········█·····█···································································
 | 
				
			||||
static const uint8_t G_BOOT_LOGO_BYTES[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0x40, 0xc0, 0xc0, 0x40, 0xc0, 0xa0, 0xa0, 0x20, 0xa0, 0xa0, 0xe0, 0x60, 0xd0, 0x90, 0xd0, 0xd0, 0xf0, 0xf0, 0xc8, 0xe8, 0xe8, 0xb8, 0xb8, 0x64, 0xd4, 0xb4, 0x94, 0x9c, 0x14, 0x0c, 0x0c, 0x1c, 0x14, 0x34, 0x34, 0x34, 0x12, 0x1a, 0x0a, 0x0a, 0x06, 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0xc0, 0x60, 0x60, 0x60, 0x50, 0x30, 0x30, 0x38, 0x3c, 0x3c, 0x2c, 0x2c, 0x3c, 0x2e, 0x2e, 0x3e, 0x3e, 0x37, 0x3d, 0x2b, 0x3f, 0x3d, 0x2f, 0x3f, 0x3f, 0x5f, 0x4d, 0xad, 0x25, 0x16, 0x1d, 0x1f, 0x1e, 0x0a, 0x1b, 0x09, 0x0d, 0x04, 0x02, 0x03, 0x03, 0xc3, 0x43, 0x43, 0x43, 0xa5, 0x63, 0x23, 0x22, 0x21, 0x91, 0xd1, 0x31, 0x11, 0x08, 0x08, 0x28, 0x58, 0x2c, 0x04, 0x34, 0x1c, 0x16, 0x0a, 0x0a, 0x16, 0x0a, 0x05, 0x01, 0x04, 0x0b, 0x0f, 0x3c, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09, 0x10, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x38, 0xe8, 0x08, 0xf4, 0x4c, 0x32, 0x29, 0x10, 0x08, 0x00, 0x10, 0x48, 0x84, 0x02, 0x05, 0x02, 0x05, 0x02, 0x01, 0x00, 0x00, 0x02, 0x05, 0x82, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x80, 0x87, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x8c, 0xb0, 0xc0, 0x80, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x11, 0x16, 0x18, 0x30, 0x28, 0x08, 0x08, 0x08, 0x08, 0x04, 0x05, 0x06, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0xa1, 0x41, 0xa1, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0c, 0x05, 0x06, 0x02, 0x02, 0x02, 0x01, 0x01, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02, 0x07, 0x02, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x7f, 0x44, 0x44, 0x44, 0x2b, 0x10, 0x00, 0x02, 0xff, 0x19, 0x29, 0x29, 0x49, 0x49, 0xc6, 0x04, 0x0a, 0x09, 0x3f, 0x49, 0x49, 0x49, 0x49, 0x41, 0x21, 0x21, 0x00, 0x50, 0x38, 0x16, 0x11, 0x16, 0x18, 0x70, 0x40, 0x00, 0x21, 0x21, 0x3f, 0x21, 0x21, 0x11, 0x09, 0x06, 0x00, 0x0a, 0x09, 0x7f, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x1e, 0x21, 0x20, 0x20, 0x20, 0x20, 0x0e, 0x11, 0x20, 0x10, 0x09, 0x06, 0x00, 0x00, 0x00, 0x07, 0x18, 0x21, 0x1f, 0x08, 0x10, 0x20, 0x10, 0x0f, 0x00, 0x00, 0x00 }; | 
				
			||||
 | 
				
			||||
static const struct BitmapImage bitmaps[] = { 
 | 
				
			||||
    { .name="boot_logo", .width=84, .height=48, .bytes=G_BOOT_LOGO_BYTES }, | 
				
			||||
    {} | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
const struct BitmapImage *Bitmap_Get(const char *name) { | 
				
			||||
    const struct BitmapImage *ptr = &bitmaps[0]; | 
				
			||||
    while (ptr->name) { | 
				
			||||
        if (0 == strcmp(ptr->name, name)) { | 
				
			||||
            return ptr; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    return NULL; | 
				
			||||
} | 
				
			||||
    
 | 
				
			||||
| 
		 After Width: | Height: | Size: 5.6 KiB  | 
@ -0,0 +1,171 @@ | 
				
			||||
use std::fs::{self,OpenOptions}; | 
				
			||||
use std::process::Command; | 
				
			||||
use std::string::ToString; | 
				
			||||
use std::io::Write; | 
				
			||||
 | 
				
			||||
fn main() { | 
				
			||||
    let mut c_constants = Vec::new(); | 
				
			||||
    let mut c_table = Vec::new(); | 
				
			||||
 | 
				
			||||
    for entry in fs::read_dir(".").unwrap() { | 
				
			||||
        let entry = entry.unwrap(); | 
				
			||||
        let path = entry.path();        
 | 
				
			||||
        
 | 
				
			||||
        if !path.display().to_string().ends_with(".ico") { | 
				
			||||
            continue; | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        let name = path.file_stem().unwrap().to_str().unwrap(); | 
				
			||||
        
 | 
				
			||||
        Command::new("/bin/convert").arg(&path).arg("./tmp.xbm").output().unwrap(); | 
				
			||||
        
 | 
				
			||||
        let content = fs::read_to_string("./tmp.xbm").unwrap(); | 
				
			||||
        
 | 
				
			||||
        println!("\n------------------------------------------------------------------------\n"); | 
				
			||||
        
 | 
				
			||||
        println!("{}", content); | 
				
			||||
        
 | 
				
			||||
        let mut lines = content.lines(); | 
				
			||||
        let l1 = lines.nth(0).unwrap(); | 
				
			||||
        let l2 = lines.nth(0).unwrap(); | 
				
			||||
        
 | 
				
			||||
        let w : usize = l1[l1.find("width").unwrap()+6..].parse().unwrap();        
 | 
				
			||||
        let h : usize = l2[l2.find("height").unwrap()+7..].parse().unwrap(); | 
				
			||||
                
 | 
				
			||||
        let a = content.find('{').unwrap() + 1; | 
				
			||||
        let b = content.find('}').unwrap();        
 | 
				
			||||
        let bytes = &content[a..b].trim(); | 
				
			||||
        
 | 
				
			||||
        let bytes = bytes.split(",") | 
				
			||||
            .map(|s| s.trim()) | 
				
			||||
            .filter(|s| !s.is_empty()) | 
				
			||||
            .map(|s| ! u8::from_str_radix(&s[2..], 16).unwrap()) | 
				
			||||
            .collect::<Vec<_>>(); | 
				
			||||
            
 | 
				
			||||
            
 | 
				
			||||
        print!("---SOURCE--\n"); | 
				
			||||
        for y in 0..h { | 
				
			||||
            for x in 0..(w-1)/8+1 { | 
				
			||||
                for xx in 0..8 {                
 | 
				
			||||
                    if (bytes[y*(((w-1)/8+1)) + x] & (1u8 << xx)) != 0 { | 
				
			||||
                        print!("█"); | 
				
			||||
                    } else { | 
				
			||||
                        print!("·"); | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
            } | 
				
			||||
             print!("\n"); | 
				
			||||
        } | 
				
			||||
        println!("---\n"); | 
				
			||||
            
 | 
				
			||||
        println!("name {},\nw {} h {},\nbytes {}", name, w, h, bytes.iter().map(|c| format!("{:#04x}", c)).collect::<Vec<_>>().join(", ")); | 
				
			||||
        
 | 
				
			||||
        let bit_xy = |x : usize, y : usize| { | 
				
			||||
            let xx = x / 8; | 
				
			||||
            let nthbit = x % 8; | 
				
			||||
            let n = y*((w-1)/8+1) + xx; | 
				
			||||
            if n >= bytes.len() { | 
				
			||||
                0u8 | 
				
			||||
            } else {            
 | 
				
			||||
                let r = ((bytes[n] & (1 << nthbit)) >> nthbit) as u8; | 
				
			||||
                r | 
				
			||||
            } | 
				
			||||
        }; | 
				
			||||
        
 | 
				
			||||
        let result_cols = w; | 
				
			||||
        let result_rows = ((h-1)/8)+1; | 
				
			||||
        
 | 
				
			||||
        let mut result = Vec::new(); | 
				
			||||
        
 | 
				
			||||
        for y in 0..result_rows { | 
				
			||||
            for x in 0..result_cols { | 
				
			||||
                let mut buf = 0u8; | 
				
			||||
                for yy in 0..8 { | 
				
			||||
                    buf |= bit_xy(x, y * 8 + yy) << yy; | 
				
			||||
                } | 
				
			||||
                result.push(buf); | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        //println!("final bytes {}", result.iter().map(|c| format!("{:#04x}", c)).collect::<Vec<_>>().join(", "));
 | 
				
			||||
        
 | 
				
			||||
        let mut render = String::new(); | 
				
			||||
        print!("---\n"); | 
				
			||||
        for y in 0..result_rows { | 
				
			||||
            for yy in 0..8 { | 
				
			||||
                if y*8+yy >= h { | 
				
			||||
                    break; | 
				
			||||
                } | 
				
			||||
                render.push_str("// "); | 
				
			||||
                for x in 0..result_cols { | 
				
			||||
                    if (result[y*result_cols + x] & (1u8 << yy)) != 0 { | 
				
			||||
                        print!("█"); | 
				
			||||
                        render.push_str("█"); | 
				
			||||
                    } else { | 
				
			||||
                        print!("·"); | 
				
			||||
                        render.push_str("·"); | 
				
			||||
                    } | 
				
			||||
                } | 
				
			||||
                if yy == 7 { | 
				
			||||
                    print!("/ end of byte row"); | 
				
			||||
                } | 
				
			||||
                render.push_str("\n"); | 
				
			||||
                print!("\n"); | 
				
			||||
            } | 
				
			||||
        } | 
				
			||||
        println!("---\n"); | 
				
			||||
        
 | 
				
			||||
        fn testchar(c : char) -> bool { | 
				
			||||
          c.is_alphanumeric() || c=='_' | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        let mut name = name.replace(|c:char|!testchar(c), "_"); | 
				
			||||
        if !name.starts_with(testchar) { | 
				
			||||
          name = format!("_{}", name); | 
				
			||||
        } | 
				
			||||
        
 | 
				
			||||
        c_constants.push(format!("\n/* {}x{}: {} */\n{}static const uint8_t G_{}_BYTES[] = {{ {} }};", 
 | 
				
			||||
            w,h, | 
				
			||||
            name, | 
				
			||||
            render, | 
				
			||||
            name.to_uppercase(), | 
				
			||||
            result.iter().map(|c| format!("{:#04x}", c)).collect::<Vec<_>>().join(", ") | 
				
			||||
        )); | 
				
			||||
        
 | 
				
			||||
        c_table.push(format!("{{ .name=\"{}\", .width={}, .height={}, .bytes=G_{}_BYTES }}", 
 | 
				
			||||
            name, | 
				
			||||
            w, h, | 
				
			||||
            name.to_uppercase() | 
				
			||||
        )); | 
				
			||||
    } | 
				
			||||
    
 | 
				
			||||
    let c_source = format!(r##"#include "bitmaps.h" | 
				
			||||
#include <stddef.h> | 
				
			||||
#include <string.h> | 
				
			||||
 | 
				
			||||
{} | 
				
			||||
 | 
				
			||||
static const struct BitmapImage bitmaps[] = {{ 
 | 
				
			||||
    {}, | 
				
			||||
    {{}} | 
				
			||||
}}; | 
				
			||||
 | 
				
			||||
const struct BitmapImage *Bitmap_Get(const char *name) {{ | 
				
			||||
    const struct BitmapImage *ptr = &bitmaps[0]; | 
				
			||||
    while (ptr->name) {{ | 
				
			||||
        if (0 == strcmp(ptr->name, name)) {{ | 
				
			||||
            return ptr; | 
				
			||||
        }} | 
				
			||||
    }} | 
				
			||||
    return NULL; | 
				
			||||
}} | 
				
			||||
    "##, 
 | 
				
			||||
        c_constants.join("\n"), | 
				
			||||
        c_table.join(",\n    ") | 
				
			||||
    ); | 
				
			||||
    
 | 
				
			||||
    let mut f = OpenOptions::new().write(true).create(true).truncate(true).open("./bitmaps.c").unwrap(); | 
				
			||||
    f.write(c_source.as_bytes()).unwrap(); | 
				
			||||
    
 | 
				
			||||
    let _ = fs::remove_file("./tmp.xbm"); | 
				
			||||
} | 
				
			||||
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.1 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
| 
		 After Width: | Height: | Size: 1.2 KiB  | 
@ -0,0 +1,71 @@ | 
				
			||||
#include "bitmaps.h" | 
				
			||||
#include <stddef.h> | 
				
			||||
#include <string.h> | 
				
			||||
 | 
				
			||||
 | 
				
			||||
/* 84x48: boot_logo */ | 
				
			||||
// ····················································································
 | 
				
			||||
// ·····································································████████·······
 | 
				
			||||
// ························································█████████████····█···██·····
 | 
				
			||||
// ···················█·······························█████····█·███·····███······█····
 | 
				
			||||
// ······█·█····································██████···██·█████··███████·········█···
 | 
				
			||||
// ·······█······························███████····██·█████·█·······███··········█····
 | 
				
			||||
// ······█·█······················███████·····███·███████··██···················██·····
 | 
				
			||||
// ···························██████·██·███·███·███████████·████·············███·······
 | 
				
			||||
// ······················████████████·██··███··█████████·█████·············██·██·······
 | 
				
			||||
// ··················█████·██·████···█·████···███████·███·············█████···██·······
 | 
				
			||||
// ·············███████████·█████████████···██·······█············█████··█·█·█·██······
 | 
				
			||||
// ············██████████·██████████··███████·················█████··█·██·█···███······
 | 
				
			||||
// ·········██████··█··████·██·███···████·█···············████···█··███··█······██·····
 | 
				
			||||
// ······███·████████████████████··██················█████··█···█·█·█···········█·█····
 | 
				
			||||
// ···███████····················██··············████·█····█·····█················█····
 | 
				
			||||
// ····██··························█·············█···█····██······················█····
 | 
				
			||||
// ··██·····························█·······█·█·█···█····██·······················█····
 | 
				
			||||
// ·█······························█·······█·█·█···█·█····························█····
 | 
				
			||||
// ·█····························██·······█·█·█·····█····················█········█····
 | 
				
			||||
// ··██······················████·█·█·█··█·······························█······█··█···
 | 
				
			||||
// ····████···················█··█·█·█··█································█······█··█···
 | 
				
			||||
// ·······█···················██·█·██··························█·········█······█··█···
 | 
				
			||||
// ·······█····················█·██······█·····················█··········█·····█··█···
 | 
				
			||||
// ·······█····················█·█········█··········█··········█·········█·····███····
 | 
				
			||||
// ········█···················█··········█···········█·········█·····██████████·······
 | 
				
			||||
// ········█····················█·········█············█·········█·███·················
 | 
				
			||||
// ········█····················█··········█···········█·······████····················
 | 
				
			||||
// ········█·····················█·········█············█·█████························
 | 
				
			||||
// ········█······················█·········█·········████·····························
 | 
				
			||||
// ········█·······················█········█····█████···██················█·█·········
 | 
				
			||||
// ·········█······················█·········█·██···························█··········
 | 
				
			||||
// ·········█······················█·······████····························█·█·········
 | 
				
			||||
// ·········█······················█····███·····················█······················
 | 
				
			||||
// ·········█·······················████·······················███·····················
 | 
				
			||||
// ·········█·····················███···························█······················
 | 
				
			||||
// ·········█········██████████████····················································
 | 
				
			||||
// ··········█·██████·····························································█····
 | 
				
			||||
// ···········█····························································█······█····
 | 
				
			||||
// ··························································█············█·······█····
 | 
				
			||||
// ··████·································█··················█······██····█··█····█····
 | 
				
			||||
// ··█···█···██████···█████████····█·····███████···███████···█·····█··█····█·██····█···
 | 
				
			||||
// ··█···█··██·····█·█·█··········█·█······█····█·█·█·······█·····█····█···█··█····█···
 | 
				
			||||
// ··████····█·····██··█··········█·█······█····█···██████··█·····█····█···█··█····█···
 | 
				
			||||
// ··█···█···██████··███████·····█···█·····█···█··███·······█·····█···█·····█·██···█···
 | 
				
			||||
// ··█····█··██········█········███████····█··█·····█·······█······█·█······█·█·█·█····
 | 
				
			||||
// ··█···█···█·██······█·····██··█····█··█████······█········█████··█········█···█·····
 | 
				
			||||
// ██████····█···███····█████···█·····██············█··································
 | 
				
			||||
// ··········█·····█···································································
 | 
				
			||||
static const uint8_t G_BOOT_LOGO_BYTES[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xc0, 0x40, 0xc0, 0xc0, 0x40, 0xc0, 0xa0, 0xa0, 0x20, 0xa0, 0xa0, 0xe0, 0x60, 0xd0, 0x90, 0xd0, 0xd0, 0xf0, 0xf0, 0xc8, 0xe8, 0xe8, 0xb8, 0xb8, 0x64, 0xd4, 0xb4, 0x94, 0x9c, 0x14, 0x0c, 0x0c, 0x1c, 0x14, 0x34, 0x34, 0x34, 0x12, 0x1a, 0x0a, 0x0a, 0x06, 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0xc0, 0x60, 0x60, 0x60, 0x50, 0x30, 0x30, 0x38, 0x3c, 0x3c, 0x2c, 0x2c, 0x3c, 0x2e, 0x2e, 0x3e, 0x3e, 0x37, 0x3d, 0x2b, 0x3f, 0x3d, 0x2f, 0x3f, 0x3f, 0x5f, 0x4d, 0xad, 0x25, 0x16, 0x1d, 0x1f, 0x1e, 0x0a, 0x1b, 0x09, 0x0d, 0x04, 0x02, 0x03, 0x03, 0xc3, 0x43, 0x43, 0x43, 0xa5, 0x63, 0x23, 0x22, 0x21, 0x91, 0xd1, 0x31, 0x11, 0x08, 0x08, 0x28, 0x58, 0x2c, 0x04, 0x34, 0x1c, 0x16, 0x0a, 0x0a, 0x16, 0x0a, 0x05, 0x01, 0x04, 0x0b, 0x0f, 0x3c, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x09, 0x09, 0x10, 0x10, 0x10, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x38, 0xe8, 0x08, 0xf4, 0x4c, 0x32, 0x29, 0x10, 0x08, 0x00, 0x10, 0x48, 0x84, 0x02, 0x05, 0x02, 0x05, 0x02, 0x01, 0x00, 0x00, 0x02, 0x05, 0x82, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x80, 0x87, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x8c, 0xb0, 0xc0, 0x80, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x11, 0x16, 0x18, 0x30, 0x28, 0x08, 0x08, 0x08, 0x08, 0x04, 0x05, 0x06, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0xa1, 0x41, 0xa1, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x0f, 0x10, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x0c, 0x05, 0x06, 0x02, 0x02, 0x02, 0x01, 0x01, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x02, 0x07, 0x02, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x7f, 0x44, 0x44, 0x44, 0x2b, 0x10, 0x00, 0x02, 0xff, 0x19, 0x29, 0x29, 0x49, 0x49, 0xc6, 0x04, 0x0a, 0x09, 0x3f, 0x49, 0x49, 0x49, 0x49, 0x41, 0x21, 0x21, 0x00, 0x50, 0x38, 0x16, 0x11, 0x16, 0x18, 0x70, 0x40, 0x00, 0x21, 0x21, 0x3f, 0x21, 0x21, 0x11, 0x09, 0x06, 0x00, 0x0a, 0x09, 0x7f, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x1e, 0x21, 0x20, 0x20, 0x20, 0x20, 0x0e, 0x11, 0x20, 0x10, 0x09, 0x06, 0x00, 0x00, 0x00, 0x07, 0x18, 0x21, 0x1f, 0x08, 0x10, 0x20, 0x10, 0x0f, 0x00, 0x00, 0x00 }; | 
				
			||||
 | 
				
			||||
static const struct BitmapImage bitmaps[] = { 
 | 
				
			||||
    { .name="boot_logo", .width=84, .height=48, .bytes=G_BOOT_LOGO_BYTES }, | 
				
			||||
    {} | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
const struct BitmapImage *Bitmap_Get(const char *name) { | 
				
			||||
    const struct BitmapImage *ptr = &bitmaps[0]; | 
				
			||||
    while (ptr->name) { | 
				
			||||
        if (0 == strcmp(ptr->name, name)) { | 
				
			||||
            return ptr; | 
				
			||||
        } | 
				
			||||
    } | 
				
			||||
    return NULL; | 
				
			||||
} | 
				
			||||
    
 | 
				
			||||
@ -0,0 +1,21 @@ | 
				
			||||
/**
 | 
				
			||||
 * TODO file description | 
				
			||||
 * 
 | 
				
			||||
 * Created on 2020/01/05. | 
				
			||||
 */ | 
				
			||||
 | 
				
			||||
#ifndef BITMAPS_H | 
				
			||||
#define BITMAPS_H | 
				
			||||
 | 
				
			||||
#include <stdint.h> | 
				
			||||
 | 
				
			||||
struct BitmapImage { | 
				
			||||
    const char *name; | 
				
			||||
    uint8_t width; | 
				
			||||
    uint8_t height; | 
				
			||||
    const uint8_t* bytes; | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
const struct BitmapImage *Bitmap_Get(const char *name); | 
				
			||||
 | 
				
			||||
#endif //BITMAPS_H
 | 
				
			||||
@ -0,0 +1,36 @@ | 
				
			||||
#include <malloc.h> | 
				
			||||
#include <stdio.h> | 
				
			||||
#include <graphics/bitmaps.h> | 
				
			||||
 | 
				
			||||
#include "scenes.h" | 
				
			||||
#include "liquid.h" | 
				
			||||
#include "analog.h" | 
				
			||||
#include "graphics/nokia.h" | 
				
			||||
#include "graphics/drawing.h" | 
				
			||||
 | 
				
			||||
struct BootScene { | 
				
			||||
    struct Scene base; | 
				
			||||
    uint32_t cnt; | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
static struct SceneEvent Boot_onTick(struct BootScene *self) { | 
				
			||||
    self->cnt += 10; // ms
 | 
				
			||||
    if (self->cnt == 2000) { | 
				
			||||
        return SceneEvent_Close(0, NULL); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    return SceneEvent_None(); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
static void Boot_paint(struct BootScene *self) | 
				
			||||
{ | 
				
			||||
    LCD_clearDisplay(0); | 
				
			||||
    LCD_setBitmap(Bitmap_Get("boot_logo")->bytes); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
struct Scene *NewScene_Boot(void) { | 
				
			||||
    struct BootScene *scene = calloc(1, sizeof(struct BootScene)); | 
				
			||||
    scene->base.paint = (Scene_paint_t) Boot_paint; | 
				
			||||
    scene->base.onTick = (Scene_onTick_t) Boot_onTick; | 
				
			||||
    return (struct Scene *) scene; | 
				
			||||
} | 
				
			||||
@ -0,0 +1,92 @@ | 
				
			||||
#include <malloc.h> | 
				
			||||
#include <stdio.h> | 
				
			||||
#include <graphics/bitmaps.h> | 
				
			||||
 | 
				
			||||
#include "scenes.h" | 
				
			||||
#include "liquid.h" | 
				
			||||
#include "analog.h" | 
				
			||||
#include "graphics/nokia.h" | 
				
			||||
#include "graphics/drawing.h" | 
				
			||||
 | 
				
			||||
/**
 | 
				
			||||
 * The struct is allocated bigger than 'Scene' to accommodate private fields. | 
				
			||||
 * Since the base struct is located at the beginning, it can be cast and passed around as Scene. | 
				
			||||
 */ | 
				
			||||
struct DemoScene { | 
				
			||||
    struct Scene base; | 
				
			||||
    int32_t pos; | 
				
			||||
    uint32_t timer_phase; | 
				
			||||
    uint32_t timer_prescale; | 
				
			||||
}; | 
				
			||||
 | 
				
			||||
static struct SceneEvent Demo_onInput(struct DemoScene *self, struct InputEvent event) { | 
				
			||||
    switch (event.kind) { | 
				
			||||
        case InputEventKind_Wheel: | 
				
			||||
            self->pos += event.wheel.delta; | 
				
			||||
            break; | 
				
			||||
 | 
				
			||||
        case InputEventKind_Button: | 
				
			||||
            if (event.button.state) { | 
				
			||||
                return SceneEvent_OpenChild(NewScene_Car(), 0); | 
				
			||||
            } | 
				
			||||
            break; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    return SceneEvent_Repaint(); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
static struct SceneEvent Demo_onTick(struct DemoScene *self) { | 
				
			||||
    // top text anim
 | 
				
			||||
    self->timer_prescale += 1; | 
				
			||||
 | 
				
			||||
    if (self->timer_prescale == 100) { | 
				
			||||
        self->timer_prescale = 0; | 
				
			||||
        self->timer_phase += 1; | 
				
			||||
        self->timer_phase = self->timer_phase & 0b11; // 0..3
 | 
				
			||||
 | 
				
			||||
        return SceneEvent_Repaint(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    return SceneEvent_None(); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
static void Demo_paint(struct DemoScene *self) | 
				
			||||
{ | 
				
			||||
    LCD_clearDisplay(0); | 
				
			||||
 | 
				
			||||
    const char *header = "???"; | 
				
			||||
    switch (self->timer_phase) { | 
				
			||||
        case 0: | 
				
			||||
            header = "Drink water"; | 
				
			||||
            break; | 
				
			||||
        case 1: | 
				
			||||
            header = " Drink water"; | 
				
			||||
            break; | 
				
			||||
        case 2: | 
				
			||||
            header = "  Drink water"; | 
				
			||||
            break; | 
				
			||||
        case 3: | 
				
			||||
            header = " Drink water"; | 
				
			||||
            break; | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    LCD_setStrEx(header, 0, 3, 1, 3); | 
				
			||||
 | 
				
			||||
    LCD_setRect(0, 12, 83, 31, 1, 1); | 
				
			||||
    char buf[10]; | 
				
			||||
//    sprintf(buf, "%3d", priv->pos);
 | 
				
			||||
//    LCD_setStr(buf, 2, 15, 0);
 | 
				
			||||
    sprintf(buf, "🌡%.0f°C", analog_read()); | 
				
			||||
    LCD_setStrEx(buf, 2, 14, 0, 2); | 
				
			||||
 | 
				
			||||
    LCD_setStr("×↑↓←→⏰⌛☸⏎🌡°🔙▶◀", 2, 33, 1); | 
				
			||||
} | 
				
			||||
 | 
				
			||||
struct Scene *NewScene_Demo(void) { | 
				
			||||
    struct DemoScene *scene = calloc(1, sizeof(struct DemoScene)); | 
				
			||||
 | 
				
			||||
    scene->base.onInput = (Scene_onInput_t) Demo_onInput; | 
				
			||||
    scene->base.paint = (Scene_paint_t) Demo_paint; | 
				
			||||
    scene->base.onTick = (Scene_onTick_t) Demo_onTick; | 
				
			||||
    return (struct Scene *) scene; | 
				
			||||
} | 
				
			||||