Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • add_menu_vibration
  • blinkisync-as-preload
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • ctx
  • dualcore
  • dx/flatten-config-module
  • dx/meh-bdf-to-stm
  • freertos-btle
  • genofire/ble-follow-py
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • plaetzchen/ios-workaround
  • rahix/bhi
  • rahix/bhi160-cleanup
  • rahix/bma
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/ble-buffers
  • schneider/ble-critical-section
  • schneider/ble-fixes-2020-3
  • schneider/ble-hid
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • schneider/ble-time
  • schneider/bonding
  • schneider/bonding-fail-if-full
  • schneider/bonding-naming
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • schneider/covid-tracing
  • schneider/default-main
  • schneider/exnostat-remove-gapple
  • schneider/fat-locking
  • schneider/fix-ble-mac-write
  • schneider/fundamental-test
  • schneider/g-watch
  • schneider/max30001
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • schneider/maxim-sdk-update
  • schneider/mp-for-old-bl
  • schneider/mpy-portstate
  • schneider/rng-btle
  • schneider/schleicher-test
  • schneider/sdk-0.2.1-11
  • schneider/sdk-0.2.1-12
  • schneider/sdk-0.2.1-7
  • schneider/spo2-playground
  • schneider/stream-locks
  • schneider/trng-enable-fix
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.10
  • v1.11
  • v1.12
  • v1.13
  • v1.14
  • v1.15
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
  • v1.7
  • v1.8
  • v1.9
79 results

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
  • add_menu_vibration
  • blinkisync-as-preload
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • dualcore
  • dx/flatten-config-module
  • dx/meh-bdf-to-stm
  • freertos-btle
  • genofire/ble-follow-py
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • plaetzchen/ios-workaround
  • rahix/bhi
  • rahix/bluetooth-app-favorite
  • rahix/bma
  • rahix/user-space-ctx
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/ancs
  • schneider/ble-buffers
  • schneider/ble-central
  • schneider/ble-ecg-stream-visu
  • schneider/ble-fixes-2020-3
  • schneider/ble-mini-demo
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • schneider/bonding
  • schneider/bonding-fail-if-full
  • schneider/bootloader-update-9a0d158
  • schneider/deepsleep
  • schneider/deepsleep2
  • schneider/deepsleep4
  • schneider/default-main
  • schneider/freertos-list-debug
  • schneider/fundamental-test
  • schneider/iaq-python
  • schneider/ir
  • schneider/max30001
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • schneider/maxim-sdk-update
  • schneider/mp-exception-print
  • schneider/mp-for-old-bl
  • schneider/png
  • schneider/schleicher-test
  • schneider/sdk-0.2.1-11
  • schneider/sdk-0.2.1-7
  • schneider/sleep-display
  • schneider/spo2-playground
  • schneider/stream-locks
  • schneider/v1.17-changelog
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.10
  • v1.11
  • v1.12
  • v1.13
  • v1.14
  • v1.15
  • v1.16
  • v1.17
  • v1.18
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
  • v1.7
  • v1.8
  • v1.9
82 results
Show changes
Commits on Source (9)
Showing
with 31733 additions and 19 deletions
...@@ -5,21 +5,39 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -5,21 +5,39 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased] ## [Unreleased]
### Added ### Added
- `leds.flash_rocket()` API for making rockets flash asynchronously. #### For Users
- Basic API for the MAX86150 pulse-oximeter.
- A feature to allow setting the main app on-device. - A feature to allow setting the main app on-device.
- Added compatibility to BLE 5.0 capable phones (including iPhones). - Added compatibility to BLE 5.0 capable phones (including iPhones).
- Added pairing dialog in BLE app. Device is only visible when BLE app is - Added a pairing dialog in the BLE app. card10 is only visible when BLE app is
active. active.
- G-Watch watch face.
- App for COVID-19 exposure notification statistics.
- Experimental app using the MAX86150 pulse-oximeter.
#### For Developers
- `leds.flash_rocket()` API for making rockets flash asynchronously.
- Basic API for the MAX86150 pulse-oximeter.
- CSPRNG as a replacement for the hardware TRNG which does not seem to produce
good entropy the way we are using it right now.
- Option to write HCI layer log files for debugging. - Option to write HCI layer log files for debugging.
- Feature in `simple_menu` which detects long button presses.
- _Stub_ `ubluetooth` module. Not yet functional! - _Stub_ `ubluetooth` module. Not yet functional!
### Changed ### Changed
- Internal changes to the way interrupts are triggered. #### For Users
- Updated to a newer version of MicryPython (v1.12). - The default watch face is now G-Watch.
- Improved BLE security by only allowing man-in-the-middle protected - Improved BLE security by only allowing man-in-the-middle protected
pairings and specifying minimum key lengths. pairings and specifying minimum key lengths.
- Read time/date automatically from iOS devices.
#### For Developers
- Updated to a newer version of MicroPython (v1.12).
- All `u{module}` MicroPython modules are now also available as `{module}` which
brings card10 more in line with upstream.
- Updated to SDK version 0.2.1-12
- The BLE pairing database was completely overhauled.
- Use the CSPRNG for all MicroPython randomness.
- Internal changes to the way interrupts are triggered.
### Fixed ### Fixed
- Made the `vibra` vibration motor API more stable. - Made the `vibra` vibration motor API more stable.
...@@ -27,6 +45,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -27,6 +45,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fixed bug which made the USB serial connection unresponsive. - Fixed bug which made the USB serial connection unresponsive.
- Fixed bug which wrote the pairings file more periodically. - Fixed bug which wrote the pairings file more periodically.
- Fixed invalid filesystem locking in BLE startup. - Fixed invalid filesystem locking in BLE startup.
- Only print a single warning when a sensor stream overflows instead of spamming
the console with errors.
- Fixed issues from reloading the configuration file.
- Fixed `pycard10.py` not properly resetting the device before loading a script.
- Allow to reopen BHI160 sensor from python.
- Fixed pycardium not exiting when triggering certain failure conditions.
- Made the config parser more robust.
## [v1.15] - 2020-02-02 - [Okra] ## [v1.15] - 2020-02-02 - [Okra]
......
...@@ -48,4 +48,6 @@ Option name Type Description ...@@ -48,4 +48,6 @@ Option name Type Description
``ble_mac`` Boolean MAC address used for BLE. Format: ``ca:4d:10:xx:xx:xx``. ``ble_mac`` Boolean MAC address used for BLE. Format: ``ca:4d:10:xx:xx:xx``.
------------------ ---------- ----------- ------------------ ---------- -----------
``ble_log_enable`` Boolean Activate HCI level logging of BLE data. Creates a new btsnoop compatible log file named ``ble.log`` in the ``logs`` folder after each boot if BLE is activated. Keeps the last 10 files. ``ble_log_enable`` Boolean Activate HCI level logging of BLE data. Creates a new btsnoop compatible log file named ``ble.log`` in the ``logs`` folder after each boot if BLE is activated. Keeps the last 10 files.
------------------ ---------- -----------
``right_scroll`` Boolean Use both right buttons to scroll up and down. Lower left button is SELECT.
================== ========== =========== ================== ========== ===========
...@@ -56,6 +56,7 @@ typedef _Bool bool; ...@@ -56,6 +56,7 @@ typedef _Bool bool;
#define API_DISP_FRAMEBUFFER 0x29 #define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_BACKLIGHT 0x2a #define API_DISP_BACKLIGHT 0x2a
#define API_DISP_PRINT_ADV 0x2b #define API_DISP_PRINT_ADV 0x2b
#define API_DISP_CTX 0x2c
/* API_BATTERY_VOLTAGE 0x30 */ /* API_BATTERY_VOLTAGE 0x30 */
#define API_BATTERY_CURRENT 0x31 #define API_BATTERY_CURRENT 0x31
...@@ -1612,6 +1613,17 @@ API(API_DISP_FRAMEBUFFER, int epic_disp_framebuffer( ...@@ -1612,6 +1613,17 @@ API(API_DISP_FRAMEBUFFER, int epic_disp_framebuffer(
union disp_framebuffer *fb union disp_framebuffer *fb
)); ));
/**
* Render a ctx drawlist. The drawlist is expected to consist of complete
* commands, i.e. not only a multiple of 9 bytes, but to not chop of CTX_CONT
* entries. The function is blocking and reads data from core1s memory
* space.
*
* :data: pointer to journal data
* :length: length of journal data, in bytes.
* :return: ``0`` on success or negative value in case of an error:
*/
API(API_DISP_CTX, int epic_disp_ctx(void *data, size_t length));
/** /**
* Set the backlight brightness. * Set the backlight brightness.
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "LCD_Driver.h" #include "LCD_Driver.h"
#include "epicardium.h" #include "epicardium.h"
#include "gfx.h" #include "gfx.h"
#include "ctx.h"
#include "gpio.h" #include "gpio.h"
#include "task.h" #include "task.h"
#include "tmr.h" #include "tmr.h"
...@@ -183,11 +184,11 @@ int epic_disp_update() ...@@ -183,11 +184,11 @@ int epic_disp_update()
if (cl < 0) { if (cl < 0) {
return cl; return cl;
} }
gfx_update(&display_screen); gfx_update(&display_screen);
return 0; return 0;
} }
int epic_disp_framebuffer(union disp_framebuffer *fb) int epic_disp_framebuffer(union disp_framebuffer *fb)
{ {
int cl = check_lock(); int cl = check_lock();
...@@ -199,6 +200,39 @@ int epic_disp_framebuffer(union disp_framebuffer *fb) ...@@ -199,6 +200,39 @@ int epic_disp_framebuffer(union disp_framebuffer *fb)
return 0; return 0;
} }
static Ctx *ctx = NULL;
int epic_disp_ctx (void *data, size_t length)
{
if (!data || (length % 9 != 0))
return -EINVAL;
if (!ctx)
{
ctx = ctx_new_for_framebuffer (
display_screen.fb->data,
DISP_WIDTH, DISP_HEIGHT,
DISP_WIDTH * 2, CTX_FORMAT_RGB565_BYTESWAPPED);
#if 1 // rotate framebuffer
//ctx_identity (ctx);
ctx_translate (ctx, DISP_WIDTH, DISP_HEIGHT);
ctx_scale (ctx, -1.0, -1.0);
#endif
}
Ctx *sctx = ctx_new_for_renderstream (data, length);
//ctx_save (ctx);
ctx_render_ctx (sctx, ctx);
//ctx_restore (ctx);
ctx_free (sctx);
#if 0 // in-lieu of better way of ensuring clean slate
ctx_free (ctx);
ctx = NULL;
#endif
return 0;
}
int epic_disp_backlight(uint16_t brightness) int epic_disp_backlight(uint16_t brightness)
{ {
/* TODO: lock? */ /* TODO: lock? */
......
...@@ -119,8 +119,12 @@ void epic_uart_write_str(const char *str, size_t length) ...@@ -119,8 +119,12 @@ void epic_uart_write_str(const char *str, size_t length)
SERIAL_WRITE_NOTIFY, SERIAL_WRITE_NOTIFY,
eSetBits eSetBits
); );
if (bytes_sent == 0) {
vTaskDelay(1);
} else {
portYIELD(); portYIELD();
} }
}
} while (index < length); } while (index < length);
} }
} }
......
CFLAGS+=-DCTX_SIMULATOR -DCARD10_CTX_STATIC -lm -Wall -I../../lib/ctx
LD_FLAGS+=-lm
ctx-demo: ctx-demo.o ui.o Makefile ../../lib/ctx/ctx.h
$(CC) -s -Os -o $@ ctx-demo.o ui.o $(LD_FLAGS)
ctx-demo.o: ctx-demo.c ui.h Makefile
$(CC) -c -Os -o $@ $< $(CFLAGS)
ui.o: ui.c ui.h Makefile
$(CC) -c -Os -o $@ $< $(CFLAGS)
test: ctx-demo
./ctx-demo
clean:
rm -f ctx-demo *.o
/*
* Copyright 2019-2020 Øyvind Kolås <pippin@gimp.org>
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <math.h>
#include "ctx.h"
#include "ui.h"
extern UiItem ctx_demo[];
#if CARD10_CTX_STATIC
#ifndef CTX_SIMULATOR
static uint16_t pixels[DISP_WIDTH * DISP_HEIGHT];
#endif
#endif
int main(int argc, char *argv[])
{
int quit = 0;
#if CARD10_CTX_STATIC
#if CTX_SIMULATOR
Ctx *ctx = ctx_new_ui (DISP_WIDTH, DISP_HEIGHT);
#else
Ctx *ctx = ctx_new_for_framebuffer (pixels, DISP_WIDTH, DISP_HEIGHT,
DISP_WIDTH * 2,
CTX_FORMAT_RGB565_BYTESWAPPED);
ctx_translate (ctx, DISP_WIDTH, DISP_HEIGHT);
ctx_scale (ctx, -1.0f, -1.0f);
#endif
#else
Ctx *ctx = ctx_new ();
ctx_set_size (ctx, DISP_WIDTH, DISP_HEIGHT); // for parser ui_items
#endif
ui_set_items (ctx_demo);
while (!quit)
{
#if CARD10_CTX_STATIC
// why can't we take a ctx_reset here? (it causes mostly blank render,
// not only transform going to identity XXX XXX
#ifdef CTX_SIMULATOR
ctx_reset (ctx);
#endif
#else
ctx_reset (ctx);
#endif
ctx_rectangle (ctx, 0, 0, DISP_WIDTH, DISP_HEIGHT);
ctx_rgba8 (ctx, 0,0,0,255);
ctx_fill (ctx);
ctx_save (ctx);
ui_item_draw_fullscreen (ctx, ui_current_scene());
ctx_restore (ctx);
#ifdef CTX_SIMULATOR
ctx_flush (ctx);
usleep (20 * 1000);
#else
epic_disp_open ();
#if CARD10_CTX_STATIC
epic_disp_framebuffer ((void*)pixels);
#else
epic_disp_ctx ((void*)ctx_get_renderstream (ctx),
ctx_get_renderstream_count (ctx) * 9);
epic_disp_update ();
#endif
epic_disp_close ();
#endif
ui_event_update (ctx);
frame_no ++;
if (ui_event_match (BUTTON_LEFT_TOP, UI_PRESS))
quit = 1;
}
return 0;
}
static void scope (Ctx *ctx, int frame_no)
{
ctx_rgba8 (ctx, 255,0,0,255);
ctx_line_width (ctx, -1);
for (int i = 0; i < 180; i++)
{
float x = i;
float y = DISP_HEIGHT*0.5f*sinf ((x+frame_no) / 10.0)+DISP_HEIGHT/2;
if (i == 0)
ctx_move_to (ctx, x, y);
else
ctx_line_to (ctx, x, y);
}
ctx_stroke (ctx);
}
static void scope2 (Ctx *ctx, int frame_no)
{
ctx_rgba8 (ctx, 255,0,0,255);
ctx_line_width (ctx, -1);
for (int i = 0; i < 180; i++)
{
float x = i;
float y = DISP_HEIGHT / 2 *
sinf ((x+frame_no)/7.0f) * cosf((x+frame_no)/3.0f) + DISP_HEIGHT/2;
if (i == 0)
ctx_move_to (ctx, x, y);
else
ctx_line_to (ctx, x, y);
}
ctx_stroke (ctx);
}
static void _analog_clock (Ctx *ctx, int frame_no, int smoothstep)
{
uint64_t ms64 = ui_ticks;
uint32_t ms = ms64;
uint32_t s = ms / 1000;
uint32_t m = s / 60;
uint32_t h = m / 60;
ms = ((uint32_t)(ms))%1000;
s %= 60;
m %= 60;
h %= 12;
float r = frame_no * 0.008;
ctx_save (ctx);
ctx_rgba8 (ctx, 127,127,127,255);
ctx_move_to (ctx, DISP_WIDTH/2 + DISP_HEIGHT * 0.45, DISP_HEIGHT/2);
ctx_arc (ctx, DISP_WIDTH/2, DISP_HEIGHT/2, DISP_HEIGHT * 0.45, 0.0, CTX_PI * 2, 0);
ctx_line_width (ctx, 8);
ctx_line_cap (ctx, CTX_CAP_NONE);
ctx_stroke (ctx);
ctx_line_width (ctx, 7);
ctx_line_cap (ctx, CTX_CAP_ROUND);
ctx_rgba8 (ctx, 188,188,188,255);
r = m * CTX_PI * 2/ 60;
ctx_move_to (ctx, DISP_WIDTH/2, DISP_HEIGHT/2);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.32f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.32f);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.33f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.33f);
ctx_stroke (ctx);
r = (h + m/60.0f) * CTX_PI * 2/ 12;
ctx_move_to (ctx, DISP_WIDTH/2, DISP_HEIGHT/2);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.25f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.25f);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.26f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.26f);
ctx_stroke (ctx);
ctx_line_width (ctx, 4);
ctx_line_cap (ctx, CTX_CAP_NONE);
ctx_rgba8 (ctx, 255,0,0,127);
if (smoothstep)
r = (s + ms/1000.0f) * CTX_PI * 2/ 60;
else
r = (s ) * CTX_PI * 2/ 60;
ctx_move_to (ctx, DISP_WIDTH/2, DISP_HEIGHT/2);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.45f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.45f);
ctx_line_to (ctx, DISP_WIDTH/2 + cosf(r) * DISP_HEIGHT * 0.46f, DISP_HEIGHT/2 + sinf (r) * DISP_HEIGHT * 0.46f);
ctx_stroke (ctx);
ctx_restore (ctx);
}
static void analog_clock (Ctx *ctx, int frame_no)
{
_analog_clock (ctx, frame_no, 1);
}
static void gradient_text (Ctx *ctx, int frame_no)
{
frame_no = frame_no % 400;
float r = frame_no * 0.01;
ctx_save (ctx);
//ctx_rgba8 (ctx, 255,255,255,255);
ctx_linear_gradient (ctx, 12, 12, 200, 200);
ctx_translate (ctx, DISP_WIDTH/2, DISP_HEIGHT/2);
ctx_rotate (ctx, r * 1.66);
ctx_translate (ctx, -DISP_WIDTH/2, -DISP_HEIGHT/2);
ctx_move_to (ctx, 0, 40);
ctx_font_size (ctx, 24);
ctx_text (ctx, "card10+ctx");
ctx_restore (ctx);
}
static void spin_text (Ctx *ctx, int frame_no)
{
UiItem *item = ui_current_scene ();
const char *string = "card10+ctx";
if (item->data) string = item->data;
frame_no = frame_no % 400;
float r = frame_no * 0.01;
ctx_save (ctx);
ctx_rgba8 (ctx, 255,255,255,255);
ctx_translate (ctx, DISP_WIDTH/2, DISP_HEIGHT/2);
ctx_rotate (ctx, r * 1.66);
ctx_translate (ctx, -DISP_WIDTH/2, -DISP_HEIGHT/2);
ctx_move_to (ctx, 0, 40);
ctx_font_size (ctx, 24);
ctx_text (ctx, string);
ctx_restore (ctx);
}
static void counter (Ctx *ctx, int frame_no)
{
UiItem *item = ui_current_scene ();
int timeout = item->arg1 * 1000;
//float r = (ui_ticks-ui_scene_timer)*1.0f/timeout;
float t = (ui_ticks-ui_scene_timer)/1000.0;
char buf[64];
ctx_rgba8 (ctx, 255,255,255,255);
ctx_move_to (ctx, 5, 30);
ctx_font_size (ctx, 14.0);
sprintf (buf, "%i%% %i/%i %i", (ui_ticks-ui_scene_timer)*100/timeout,
ui_ticks-ui_scene_timer, timeout, (int)(t*10));
ctx_text (ctx, buf);
}
static void font_scaling (Ctx *ctx, int frame_no)
{
char buf[64];
ctx_rgba8 (ctx, 255,255,255,255);
ctx_move_to (ctx, 5, 40 - (frame_no % 50));
ctx_font_size (ctx, ui_font_size);
ctx_text (ctx, "Press top right to change\nfont size, press lower right\nto advance to next test.\nThis text is moving\none pixel per frame.");
ctx_move_to (ctx, 0, 15);
ctx_font_size (ctx, 12.0);
sprintf (buf, "size: %i", (int)ui_font_size);
ctx_text (ctx, buf);
if (ui_event_match (BUTTON_RIGHT_TOP, UI_PRESS_REPEAT))
{
ui_font_size += 1;
if (ui_font_size > 40.0f) ui_font_size = 4.0f;
}
}
static void circle_spiral (Ctx *ctx, int frame_no)
{
UiItem *item = ui_current_scene ();
int timeout = item->arg1 * 1000;
float r = (ui_ticks-ui_scene_timer)*1.0f/timeout;
//float t = (ui_ticks-ui_scene_timer)/1000.0;
static int dot_count = 2;
static float twist = 2.9645;
static float dot_scale = 52.0;
if (frame_no == 0)
{
dot_count = 2;
twist = 2.9645;
dot_scale = 52.0;
}
twist = 2.9645 * (1.0 -r) + r * 3.0;
dot_count = 2.0 * (1.0 - r) + r * 256;
ctx_rgba(ctx, 1, 1, 1, 0.5);
for (int i = 0; i < dot_count; i ++)
{
float x = DISP_WIDTH / 2;
float y = DISP_HEIGHT / 2;
float radius = DISP_HEIGHT / dot_scale;
float dist = i * (DISP_HEIGHT/ 2) / (dot_count * 1.0f);
float twisted = (i * twist);
float cos_twisted = cosf (twisted);
float sin_twisted = sinf (twisted);
x += cos_twisted * dist;
y += sin_twisted * dist;
ctx_arc (ctx, x, y, radius, 0, CTX_PI * 2.1, 0);
ctx_fill (ctx);
}
#if 0
itk_panel_start (itk, "spiraling dots", ctx_width(ctx)*3/4,0,ctx_width(ctx)/4, ctx_height(ctx)/3);
itk_slider_int (itk, "count", &dot_count, 1, 4000, 10);
itk_slider_float (itk, "radius", &dot_scale, 2.0, 200.0, 4.5);
itk_slider_float (itk, "twist amount", &twist, -3.14152, 3.14152, 0.0005);
#endif
}
static void parser (Ctx *ctx, int frame_no)
{
UiItem *item = ui_current_scene ();
if (item->data)
{
ctx_parse (ctx, item->data);
}
else
{
}
}
static void launch (Ctx *ctx, void *user_data)
{
ui_autoplay = 1;
ui_ui_autoplay_timeout = 4000;
ui_title_timeout = 2000;
//ui_font_size = 19;
ui_no = 7;
}
extern int ui_long_press_delay;
extern int ui_press_repeat_delay;
UiItem ctx_demo[]={
//{"counter", ui_scene, counter, "ctx", 2.0},
//{"counter", ui_scene, counter, "ctx", 4.0},
{"spin text", ui_scene, spin_text, "ctx", 1.0},
//{"counter", ui_scene, counter, "ctx", 1.0},
// {"spin text", ui_scene, spin_text, "foo", 1.0},
// {"spin text", ui_scene, spin_text, "bar", 2.0},
{"ctx demo", ui_menu},
{"launch", ui_button, launch, NULL},
{"setup", ui_sub_menu},
{"", ui_separator},
{"analog clock", ui_scene, analog_clock},
{"circle spiral", ui_scene, circle_spiral, NULL, 10.0},
{"sine", ui_scene, scope},
{"gradient text", ui_scene, gradient_text},
{"complex signal", ui_scene, scope2},
{"parser", ui_scene, parser, "rgb 0 0 1 rectangle 4 4 4 4 fill "},
{"parser", ui_scene, parser,
"rgb 1 0 0 rectangle 10, 10, 40, 40 fill "
"rgb 1 1 0 ui_font_size 20 m 15 30x 'hello' "},
{"long string", ui_scene, font_scaling},
{"spin text", ui_scene, spin_text},
{"setup", ui_menu},
{"autoplay", ui_boolean_toggle, &ui_autoplay},
{"autoplay timeout", ui_int_slider, &ui_ui_autoplay_timeout, NULL, 1, 20000, 500},
{"title timeout ms", ui_int_slider, &ui_title_timeout, NULL, 1, 20000, 500},
{"", ui_separator},
{"font size", ui_float_slider, &ui_font_size, NULL, 4.0, 50.0, 1},
{"line height", ui_float_slider, &ui_line_height, NULL, 0.5, 2.0, 0.05},
{"scroll jump", ui_float_slider, &ui_scroll_jump, NULL, 0.0, 1.0, 0.05},
{"long press ms", ui_int_slider, &ui_long_press_delay, NULL, 10, 1000, 10},
{"press repeat ms", ui_int_slider, &ui_press_repeat_delay, NULL, 10, 1000, 10},
{NULL, NULL},
};
name = 'ctx-demo'
elf = executable(
name + '.elf',
['ctx-demo.c',
'ui.c',
'ui.h'
],
build_by_default: true,
dependencies: [l0dable_startup, api_caller],
link_whole: [l0dable_startup_lib],
link_args: [
'-s', '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map'
],
pie: true,
c_args: [ '-Wno-unused-function',
'-Wno-missing-field-initializers',
'-I../lib/ctx',
'-Os',
'-s', '-fomit-frame-pointer' ]
)
elf = executable(
name + '-static.elf',
['ctx-demo.c',
'ui.c',
'ui.h'
],
build_by_default: true,
dependencies: [l0dable_startup, api_caller],
link_whole: [l0dable_startup_lib],
link_args: [
'-s', '-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map'
],
pie: true,
c_args: [ '-Wno-unused-function',
'-Wno-missing-field-initializers',
'-I../lib/ctx',
'-O3',
'-DCARD10_CTX_STATIC=1', '-s', '-fomit-frame-pointer' ]
)
This diff is collapsed.
#ifndef __UI_H_
#define __UI_H_
/*
* Copyright 2019-2020 Øyvind Kolås <pippin@gimp.org>
*/
#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if CTX_SIMULATOR
#define DISP_WIDTH 160
#define DISP_HEIGHT 80
enum epic_button {
/** ``1``, Bottom left button (bit 0). */
BUTTON_LEFT_BOTTOM = 1,
/** ``2``, Bottom right button (bit 1). */
BUTTON_RIGHT_BOTTOM = 2,
/** ``4``, Top right button (bit 2). */
BUTTON_RIGHT_TOP = 4,
/** ``8``, Top left (power) button (bit 3). */
BUTTON_LEFT_TOP = 8,
/** ``8``, Top left (power) button (bit 3). */
BUTTON_RESET = 8,
};
#else
#include "epicardium.h"
#endif
typedef enum {
ITEM_DRAW_BACKGROUND, /* draws the round rectangle highlighting selected item,
*/
ITEM_DRAW,
ITEM_HEIGHT, /* returns vertical space occupied by item */
ITEM_ACTIVATE, /* upper right from menu, can for a toggle button
or button activating trigger event
*/
ITEM_ACTIVE_EVENTS, /* handle events for when this item is selected and
activated */
ITEM_DRAW_FULLSCREEN /* draw this item full screen, makes most sense
for menu and other custom top-level handlers
*/
} UiItemAction;
enum _UiEventType
{
UI_PRESSED,
UI_PRESS,
UI_PRESS_REPEAT,
UI_LONG_PRESS,
UI_RELEASE,
};
typedef enum _UiEventType UiEventType;
int ui_event_update (Ctx *ctx);
int ui_event_match (int button, UiEventType type);
/* XXX globals */
extern int frame_no;
extern unsigned int ui_scene_timer;
extern int ui_no; /* the item in the UI to run fullscreen,
if it is a menu, that menu is rendered -
but this can also be used for other
UI control, where the menus are only
one of the states
*/
extern float ui_font_size;
extern float ui_line_height;
extern float ui_y;
extern float ui_x;
//extern int ui_start_menu;
typedef struct _UiItem UiItem;
struct _UiItem{
const char *title;
float (*handler)(Ctx *ctx, UiItem *item, UiItemAction action);
void *value; /* */
void *data;
float arg1;
float arg2;
float arg3;
};
void ui_set_items (UiItem *items);
float ui_item_draw_fullscreen (Ctx *ctx, UiItem *item);
float ui_item_height (Ctx *ctx, UiItem *item);
float ui_menu (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_label (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_separator (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_button (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_boolean_toggle (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_float_slider (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_int_slider (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_sub_menu (Ctx *ctx, UiItem *item, UiItemAction action);
float ui_scene (Ctx *ctx, UiItem *item, UiItemAction action);
//unsigned int ui_ticks_live (void);
extern unsigned int ui_ticks;
extern int ui_autoplay;
extern int ui_ui_autoplay_timeout;
extern int ui_title_timeout;
extern float ui_scroll_jump;
UiItem *ui_current_scene (void);
void ui_reset_timer (void);
//int ui_find_menu (const char *name);
void ui_advance (void);
void ui_reverse (void);
int ui_event_update ();
int ui_event_match (int button, UiEventType event_type);
#endif
subdir('lib/') subdir('lib/')
subdir('blinky/') subdir('blinky/')
subdir('ctx-demo/')
...@@ -18,6 +18,7 @@ deps = [ ...@@ -18,6 +18,7 @@ deps = [
bme680, bme680,
board_card10, board_card10,
libgfx, libgfx,
libctx,
max77650, max77650,
max86150, max86150,
periphdriver, periphdriver,
......
#ifndef CTX_FONT_ascii
/* this is a ctx encoded font based on DejaVuSans.ttf */
/* CTX_SUBDIV:4 CTX_BAKE_FONT_SIZE:160 */
/* glyphs covered:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
jklmnopqrstuvwxyz{|}~ */
static const struct __attribute__ ((packed)) {uint8_t code; uint32_t a; uint32_t b;}
ctx_font_ascii[]={
{'@', 0x00000020, 0x00002bb0},/* x-advance: 43.687500 */
{'@', 0x00000021, 0x00003719},/* ! x-advance: 55.097656 */
{'@', 0x00000022, 0x00003f38},/* " x-advance: 63.218750 */
{'@', 0x00000023, 0x0000732a},/* # x-advance: 115.164062 */
{'@', 0x00000024, 0x00005773},/* $ x-advance: 87.449219 */
{'@', 0x00000025, 0x0000829a},/* % x-advance: 130.601562 */
{'@', 0x00000026, 0x00006b2e},/* & x-advance: 107.179688 */
{'@', 0x00000027, 0x000025c9},/* ' x-advance: 37.785156 */
{'@', 0x00000028, 0x0000359f},/* ( x-advance: 53.621094 */
{'@', 0x00000029, 0x0000359f},/* ) x-advance: 53.621094 */
{'@', 0x0000002a, 0x000044b9},/* * x-advance: 68.722656 */
{'@', 0x0000002b, 0x0000732a},/* + x-advance: 115.164062 */
{'@', 0x0000002c, 0x00002bb0},/* , x-advance: 43.687500 */
{'@', 0x0000002d, 0x00003198},/* - x-advance: 49.593750 */
{'@', 0x0000002e, 0x00002bb0},/* . x-advance: 43.687500 */
{'@', 0x0000002f, 0x00002e4f},/* / x-advance: 46.308594 */
{'@', 0x00000030, 0x00005773},/* 0 x-advance: 87.449219 */
{'@', 0x00000031, 0x00005773},/* 1 x-advance: 87.449219 */
{'@', 0x00000032, 0x00005773},/* 2 x-advance: 87.449219 */
{'@', 0x00000033, 0x00005773},/* 3 x-advance: 87.449219 */
{'@', 0x00000034, 0x00005773},/* 4 x-advance: 87.449219 */
{'@', 0x00000035, 0x00005773},/* 5 x-advance: 87.449219 */
{'@', 0x00000036, 0x00005773},/* 6 x-advance: 87.449219 */
{'@', 0x00000037, 0x00005773},/* 7 x-advance: 87.449219 */
{'@', 0x00000038, 0x00005773},/* 8 x-advance: 87.449219 */
{'@', 0x00000039, 0x00005773},/* 9 x-advance: 87.449219 */
{'@', 0x0000003a, 0x00002e4f},/* : x-advance: 46.308594 */
{'@', 0x0000003b, 0x00002e4f},/* ; x-advance: 46.308594 */
{'@', 0x0000003c, 0x0000732a},/* < x-advance: 115.164062 */
{'@', 0x0000003d, 0x0000732a},/* = x-advance: 115.164062 */
{'@', 0x0000003e, 0x0000732a},/* > x-advance: 115.164062 */
{'@', 0x0000003f, 0x000048f3},/* ? x-advance: 72.949219 */
{'@', 0x00000040, 0x00008973},/* @ x-advance: 137.449219 */
{'@', 0x00000041, 0x00005e06},/* A x-advance: 94.023438 */
{'@', 0x00000042, 0x00005e4b},/* B x-advance: 94.292969 */
{'@', 0x00000043, 0x00005ff9},/* C x-advance: 95.972656 */
{'@', 0x00000044, 0x000069d6},/* D x-advance: 105.835938 */
{'@', 0x00000045, 0x000056d8},/* E x-advance: 86.843750 */
{'@', 0x00000046, 0x00004f0f},/* F x-advance: 79.058594 */
{'@', 0x00000047, 0x00006a82},/* G x-advance: 106.507812 */
{'@', 0x00000048, 0x0000675b},/* H x-advance: 103.355469 */
{'@', 0x00000049, 0x00002889},/* I x-advance: 40.535156 */
{'@', 0x0000004a, 0x00002889},/* J x-advance: 40.535156 */
{'@', 0x0000004b, 0x00005a22},/* K x-advance: 90.132812 */
{'@', 0x0000004c, 0x00004c93},/* L x-advance: 76.574219 */
{'@', 0x0000004d, 0x00007697},/* M x-advance: 118.589844 */
{'@', 0x0000004e, 0x000066d1},/* N x-advance: 102.816406 */
{'@', 0x0000004f, 0x00006c30},/* O x-advance: 108.187500 */
{'@', 0x00000050, 0x000052e2},/* P x-advance: 82.882812 */
{'@', 0x00000051, 0x00006c30},/* Q x-advance: 108.187500 */
{'@', 0x00000052, 0x00005f80},/* R x-advance: 95.500000 */
{'@', 0x00000053, 0x0000573f},/* S x-advance: 87.246094 */
{'@', 0x00000054, 0x000053f5},/* T x-advance: 83.957031 */
{'@', 0x00000055, 0x0000649a},/* U x-advance: 100.601562 */
{'@', 0x00000056, 0x00005e06},/* V x-advance: 94.023438 */
{'@', 0x00000057, 0x000087e7},/* W x-advance: 135.902344 */
{'@', 0x00000058, 0x00005e29},/* X x-advance: 94.160156 */
{'@', 0x00000059, 0x000053f5},/* Y x-advance: 83.957031 */
{'@', 0x0000005a, 0x00005e29},/* Z x-advance: 94.160156 */
{'@', 0x0000005b, 0x0000359f},/* [ x-advance: 53.621094 */
{'@', 0x0000005c, 0x00002e4f},/* \ x-advance: 46.308594 */
{'@', 0x0000005d, 0x0000359f},/* ] x-advance: 53.621094 */
{'@', 0x0000005e, 0x0000732a},/* ^ x-advance: 115.164062 */
{'@', 0x0000005f, 0x000044b9},/* _ x-advance: 68.722656 */
{'@', 0x00000060, 0x000044b9},/* ` x-advance: 68.722656 */
{'@', 0x00000061, 0x0000543a},/* a x-advance: 84.226562 */
{'@', 0x00000062, 0x0000573f},/* b x-advance: 87.246094 */
{'@', 0x00000063, 0x00004b92},/* c x-advance: 75.570312 */
{'@', 0x00000064, 0x0000573f},/* d x-advance: 87.246094 */
{'@', 0x00000065, 0x00005490},/* e x-advance: 84.562500 */
{'@', 0x00000066, 0x00003063},/* f x-advance: 48.386719 */
{'@', 0x00000067, 0x0000573f},/* g x-advance: 87.246094 */
{'@', 0x00000068, 0x0000571d},/* h x-advance: 87.113281 */
{'@', 0x00000069, 0x00002630},/* i x-advance: 38.187500 */
{'@', 0x0000006a, 0x00002630},/* j x-advance: 38.187500 */
{'@', 0x0000006b, 0x00004f98},/* k x-advance: 79.593750 */
{'@', 0x0000006c, 0x00002630},/* l x-advance: 38.187500 */
{'@', 0x0000006d, 0x000085e4},/* m x-advance: 133.890625 */
{'@', 0x0000006e, 0x0000571d},/* n x-advance: 87.113281 */
{'@', 0x0000006f, 0x00005418},/* o x-advance: 84.093750 */
{'@', 0x00000070, 0x0000573f},/* p x-advance: 87.246094 */
{'@', 0x00000071, 0x0000573f},/* q x-advance: 87.246094 */
{'@', 0x00000072, 0x00003882},/* r x-advance: 56.507812 */
{'@', 0x00000073, 0x0000479c},/* s x-advance: 71.609375 */
{'@', 0x00000074, 0x000035e4},/* t x-advance: 53.890625 */
{'@', 0x00000075, 0x0000571d},/* u x-advance: 87.113281 */
{'@', 0x00000076, 0x00005157},/* v x-advance: 81.339844 */
{'@', 0x00000077, 0x0000706a},/* w x-advance: 112.414062 */
{'@', 0x00000078, 0x00005157},/* x x-advance: 81.339844 */
{'@', 0x00000079, 0x00005157},/* y x-advance: 81.339844 */
{'@', 0x0000007a, 0x00004825},/* z x-advance: 72.144531 */
{'@', 0x0000007b, 0x00005773},/* { x-advance: 87.449219 */
{'@', 0x0000007c, 0x00002e4f},/* | x-advance: 46.308594 */
{'@', 0x0000007d, 0x00005773},/* } x-advance: 87.449219 */
{'@', 0x0000007e, 0x0000732a},/* ~ x-advance: 115.164062 */
};
#define CTX_FONT_ascii 1
#endif
#ifndef CTX_FONT_regular
/* this is a ctx encoded font based on DejaVuSans.ttf */
/* CTX_SUBDIV:4 CTX_BAKE_FONT_SIZE:160 */
/* glyphs covered:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
jklmnopqrstuvwxyz{|}~éñÑßæøåö£ÆÖØÅ€§π°üÜ…”“«»©®™⏎⌫⌨·←↑↓→☣☀☁☂☢☭☮☯☽✉⚙⚠␣²◆♥♦♣
♠▲▼÷≈±≥≤½¼╴−╶╵╷┛┓┣╋┳┻┫┗┏┃━⎢⎥ */
static const struct __attribute__ ((packed)) {uint8_t code; uint32_t a; uint32_t b;}
ctx_font_regular[]={
{'@', 0x00000020, 0x00002bb0},/* x-advance: 43.687500 */
{'@', 0x00000021, 0x00003719},/* ! x-advance: 55.097656 */
{'@', 0x00000022, 0x00003f38},/* " x-advance: 63.218750 */
{'@', 0x00000023, 0x0000732a},/* # x-advance: 115.164062 */
{'@', 0x00000024, 0x00005773},/* $ x-advance: 87.449219 */
{'@', 0x00000025, 0x0000829a},/* % x-advance: 130.601562 */
{'@', 0x00000026, 0x00006b2e},/* & x-advance: 107.179688 */
{'@', 0x00000027, 0x000025c9},/* ' x-advance: 37.785156 */
{'@', 0x00000028, 0x0000359f},/* ( x-advance: 53.621094 */
{'@', 0x00000029, 0x0000359f},/* ) x-advance: 53.621094 */
{'@', 0x0000002a, 0x000044b9},/* * x-advance: 68.722656 */
{'@', 0x0000002b, 0x0000732a},/* + x-advance: 115.164062 */
{'@', 0x0000002c, 0x00002bb0},/* , x-advance: 43.687500 */
{'@', 0x0000002d, 0x00003198},/* - x-advance: 49.593750 */
{'@', 0x0000002e, 0x00002bb0},/* . x-advance: 43.687500 */
{'@', 0x0000002f, 0x00002e4f},/* / x-advance: 46.308594 */
{'@', 0x00000030, 0x00005773},/* 0 x-advance: 87.449219 */
{'@', 0x00000031, 0x00005773},/* 1 x-advance: 87.449219 */
{'@', 0x00000032, 0x00005773},/* 2 x-advance: 87.449219 */
{'@', 0x00000033, 0x00005773},/* 3 x-advance: 87.449219 */
{'@', 0x00000034, 0x00005773},/* 4 x-advance: 87.449219 */
{'@', 0x00000035, 0x00005773},/* 5 x-advance: 87.449219 */
{'@', 0x00000036, 0x00005773},/* 6 x-advance: 87.449219 */
{'@', 0x00000037, 0x00005773},/* 7 x-advance: 87.449219 */
{'@', 0x00000038, 0x00005773},/* 8 x-advance: 87.449219 */
{'@', 0x00000039, 0x00005773},/* 9 x-advance: 87.449219 */
{'@', 0x0000003a, 0x00002e4f},/* : x-advance: 46.308594 */
{'@', 0x0000003b, 0x00002e4f},/* ; x-advance: 46.308594 */
{'@', 0x0000003c, 0x0000732a},/* < x-advance: 115.164062 */
{'@', 0x0000003d, 0x0000732a},/* = x-advance: 115.164062 */
{'@', 0x0000003e, 0x0000732a},/* > x-advance: 115.164062 */
{'@', 0x0000003f, 0x000048f3},/* ? x-advance: 72.949219 */
{'@', 0x00000040, 0x00008973},/* @ x-advance: 137.449219 */
{'@', 0x00000041, 0x00005e06},/* A x-advance: 94.023438 */
{'@', 0x00000042, 0x00005e4b},/* B x-advance: 94.292969 */
{'@', 0x00000043, 0x00005ff9},/* C x-advance: 95.972656 */
{'@', 0x00000044, 0x000069d6},/* D x-advance: 105.835938 */
{'@', 0x00000045, 0x000056d8},/* E x-advance: 86.843750 */
{'@', 0x00000046, 0x00004f0f},/* F x-advance: 79.058594 */
{'@', 0x00000047, 0x00006a82},/* G x-advance: 106.507812 */
{'@', 0x00000048, 0x0000675b},/* H x-advance: 103.355469 */
{'@', 0x00000049, 0x00002889},/* I x-advance: 40.535156 */
{'@', 0x0000004a, 0x00002889},/* J x-advance: 40.535156 */
{'@', 0x0000004b, 0x00005a22},/* K x-advance: 90.132812 */
{'@', 0x0000004c, 0x00004c93},/* L x-advance: 76.574219 */
{'@', 0x0000004d, 0x00007697},/* M x-advance: 118.589844 */
{'@', 0x0000004e, 0x000066d1},/* N x-advance: 102.816406 */
{'@', 0x0000004f, 0x00006c30},/* O x-advance: 108.187500 */
{'@', 0x00000050, 0x000052e2},/* P x-advance: 82.882812 */
{'@', 0x00000051, 0x00006c30},/* Q x-advance: 108.187500 */
{'@', 0x00000052, 0x00005f80},/* R x-advance: 95.500000 */
{'@', 0x00000053, 0x0000573f},/* S x-advance: 87.246094 */
{'@', 0x00000054, 0x000053f5},/* T x-advance: 83.957031 */
{'@', 0x00000055, 0x0000649a},/* U x-advance: 100.601562 */
{'@', 0x00000056, 0x00005e06},/* V x-advance: 94.023438 */
{'@', 0x00000057, 0x000087e7},/* W x-advance: 135.902344 */
{'@', 0x00000058, 0x00005e29},/* X x-advance: 94.160156 */
{'@', 0x00000059, 0x000053f5},/* Y x-advance: 83.957031 */
{'@', 0x0000005a, 0x00005e29},/* Z x-advance: 94.160156 */
{'@', 0x0000005b, 0x0000359f},/* [ x-advance: 53.621094 */
{'@', 0x0000005c, 0x00002e4f},/* \ x-advance: 46.308594 */
{'@', 0x0000005d, 0x0000359f},/* ] x-advance: 53.621094 */
{'@', 0x0000005e, 0x0000732a},/* ^ x-advance: 115.164062 */
{'@', 0x0000005f, 0x000044b9},/* _ x-advance: 68.722656 */
{'@', 0x00000060, 0x000044b9},/* ` x-advance: 68.722656 */
{'@', 0x00000061, 0x0000543a},/* a x-advance: 84.226562 */
{'@', 0x00000062, 0x0000573f},/* b x-advance: 87.246094 */
{'@', 0x00000063, 0x00004b92},/* c x-advance: 75.570312 */
{'@', 0x00000064, 0x0000573f},/* d x-advance: 87.246094 */
{'@', 0x00000065, 0x00005490},/* e x-advance: 84.562500 */
{'@', 0x00000066, 0x00003063},/* f x-advance: 48.386719 */
{'@', 0x00000067, 0x0000573f},/* g x-advance: 87.246094 */
{'@', 0x00000068, 0x0000571d},/* h x-advance: 87.113281 */
{'@', 0x00000069, 0x00002630},/* i x-advance: 38.187500 */
{'@', 0x0000006a, 0x00002630},/* j x-advance: 38.187500 */
{'@', 0x0000006b, 0x00004f98},/* k x-advance: 79.593750 */
{'@', 0x0000006c, 0x00002630},/* l x-advance: 38.187500 */
{'@', 0x0000006d, 0x000085e4},/* m x-advance: 133.890625 */
{'@', 0x0000006e, 0x0000571d},/* n x-advance: 87.113281 */
{'@', 0x0000006f, 0x00005418},/* o x-advance: 84.093750 */
{'@', 0x00000070, 0x0000573f},/* p x-advance: 87.246094 */
{'@', 0x00000071, 0x0000573f},/* q x-advance: 87.246094 */
{'@', 0x00000072, 0x00003882},/* r x-advance: 56.507812 */
{'@', 0x00000073, 0x0000479c},/* s x-advance: 71.609375 */
{'@', 0x00000074, 0x000035e4},/* t x-advance: 53.890625 */
{'@', 0x00000075, 0x0000571d},/* u x-advance: 87.113281 */
{'@', 0x00000076, 0x00005157},/* v x-advance: 81.339844 */
{'@', 0x00000077, 0x0000706a},/* w x-advance: 112.414062 */
{'@', 0x00000078, 0x00005157},/* x x-advance: 81.339844 */
{'@', 0x00000079, 0x00005157},/* y x-advance: 81.339844 */
{'@', 0x0000007a, 0x00004825},/* z x-advance: 72.144531 */
{'@', 0x0000007b, 0x00005773},/* { x-advance: 87.449219 */
{'@', 0x0000007c, 0x00002e4f},/* | x-advance: 46.308594 */
{'@', 0x0000007d, 0x00005773},/* } x-advance: 87.449219 */
{'@', 0x0000007e, 0x0000732a},/* ~ x-advance: 115.164062 */
{'@', 0x000000e9, 0x00005490},/* é x-advance: 84.562500 */
{'@', 0x000000f1, 0x0000571d},/* ñ x-advance: 87.113281 */
{'@', 0x000000d1, 0x000066d1},/* Ñ x-advance: 102.816406 */
{'@', 0x000000df, 0x00005693},/* ß x-advance: 86.574219 */
{'@', 0x000000e6, 0x000086f7},/* æ x-advance: 134.964844 */
{'@', 0x000000f8, 0x00005418},/* ø x-advance: 84.093750 */
{'@', 0x000000e5, 0x0000543a},/* å x-advance: 84.226562 */
{'@', 0x000000f6, 0x00005418},/* ö x-advance: 84.093750 */
{'@', 0x000000a3, 0x00005773},/* £ x-advance: 87.449219 */
{'@', 0x000000c6, 0x000085e4},/* Æ x-advance: 133.890625 */
{'@', 0x000000d6, 0x00006c30},/* Ö x-advance: 108.187500 */
{'@', 0x000000d8, 0x00006c30},/* Ø x-advance: 108.187500 */
{'@', 0x000000c5, 0x00005e06},/* Å x-advance: 94.023438 */
{'@', 0x000020ac, 0x00005773},/* € x-advance: 87.449219 */
{'@', 0x000000a7, 0x000044b9},/* § x-advance: 68.722656 */
{'@', 0x000003c0, 0x000052c0},/* π x-advance: 82.750000 */
{'@', 0x000000b0, 0x000044b9},/* ° x-advance: 68.722656 */
{'@', 0x000000fc, 0x0000571d},/* ü x-advance: 87.113281 */
{'@', 0x000000dc, 0x0000649a},/* Ü x-advance: 100.601562 */
{'@', 0x00002026, 0x00008973},/* … x-advance: 137.449219 */
{'@', 0x0000201d, 0x00004735},/* ” x-advance: 71.207031 */
{'@', 0x0000201c, 0x00004735},/* “ x-advance: 71.207031 */
{'@', 0x000000ab, 0x00005418},/* « x-advance: 84.093750 */
{'@', 0x000000bb, 0x00005418},/* » x-advance: 84.093750 */
{'@', 0x000000a9, 0x00008973},/* © x-advance: 137.449219 */
{'@', 0x000000ae, 0x00008973},/* ® x-advance: 137.449219 */
{'@', 0x00002122, 0x00008973},/* ™ x-advance: 137.449219 */
{'@', 0x000023ce, 0x0000732a},/* ⏎ x-advance: 115.164062 */
{'@', 0x0000232b, 0x0000c25c},/* ⌫ x-advance: 194.359375 */
{'@', 0x00002328, 0x0000c663},/* ⌨ x-advance: 198.386719 */
{'@', 0x000000b7, 0x00002bb0},/* · x-advance: 43.687500 */
{'@', 0x00002190, 0x0000732a},/* ← x-advance: 115.164062 */
{'@', 0x00002191, 0x0000732a},/* ↑ x-advance: 115.164062 */
{'@', 0x00002193, 0x0000732a},/* ↓ x-advance: 115.164062 */
{'@', 0x00002192, 0x0000732a},/* → x-advance: 115.164062 */
{'@', 0x00002623, 0x00007b38},/* ☣ x-advance: 123.218750 */
{'@', 0x00002600, 0x00007b38},/* ☀ x-advance: 123.218750 */
{'@', 0x00002601, 0x00008973},/* ☁ x-advance: 137.449219 */
{'@', 0x00002602, 0x00007b38},/* ☂ x-advance: 123.218750 */
{'@', 0x00002622, 0x00007b38},/* ☢ x-advance: 123.218750 */
{'@', 0x0000262d, 0x00007b38},/* ☭ x-advance: 123.218750 */
{'@', 0x0000262e, 0x00007b38},/* ☮ x-advance: 123.218750 */
{'@', 0x0000262f, 0x00007b38},/* ☯ x-advance: 123.218750 */
{'@', 0x0000263d, 0x00007b38},/* ☽ x-advance: 123.218750 */
{'@', 0x00002709, 0x0000732a},/* ✉ x-advance: 115.164062 */
{'@', 0x00002699, 0x00007b38},/* ⚙ x-advance: 123.218750 */
{'@', 0x000026a0, 0x00007b38},/* ⚠ x-advance: 123.218750 */
{'@', 0x00002423, 0x0000573f},/* ␣ x-advance: 87.246094 */
{'@', 0x000000b2, 0x00003719},/* ² x-advance: 55.097656 */
{'@', 0x000025c6, 0x000069b4},/* ◆ x-advance: 105.703125 */
{'@', 0x00002665, 0x00007b38},/* ♥ x-advance: 123.218750 */
{'@', 0x00002666, 0x00007b38},/* ♦ x-advance: 123.218750 */
{'@', 0x00002663, 0x00007b38},/* ♣ x-advance: 123.218750 */
{'@', 0x00002660, 0x00007b38},/* ♠ x-advance: 123.218750 */
{'@', 0x000025b2, 0x000069b4},/* ▲ x-advance: 105.703125 */
{'@', 0x000025bc, 0x000069b4},/* ▼ x-advance: 105.703125 */
{'@', 0x000000f7, 0x0000732a},/* ÷ x-advance: 115.164062 */
{'@', 0x00002248, 0x0000732a},/* ≈ x-advance: 115.164062 */
{'@', 0x000000b1, 0x0000732a},/* ± x-advance: 115.164062 */
{'@', 0x00002265, 0x0000732a},/* ≥ x-advance: 115.164062 */
{'@', 0x00002264, 0x0000732a},/* ≤ x-advance: 115.164062 */
{'@', 0x000000bd, 0x00008538},/* ½ x-advance: 133.218750 */
{'@', 0x000000bc, 0x00008538},/* ¼ x-advance: 133.218750 */
{'@', 0x00002574, 0x000052c0},/* ╴ x-advance: 82.750000 */
{'@', 0x00002212, 0x0000732a},/* − x-advance: 115.164062 */
{'@', 0x00002576, 0x000052c0},/* ╶ x-advance: 82.750000 */
{'@', 0x00002575, 0x000052c0},/* ╵ x-advance: 82.750000 */
{'@', 0x00002577, 0x000052c0},/* ╷ x-advance: 82.750000 */
{'@', 0x0000251b, 0x000052c0},/* ┛ x-advance: 82.750000 */
{'@', 0x00002513, 0x000052c0},/* ┓ x-advance: 82.750000 */
{'@', 0x00002523, 0x000052c0},/* ┣ x-advance: 82.750000 */
{'@', 0x0000254b, 0x000052c0},/* ╋ x-advance: 82.750000 */
{'@', 0x00002533, 0x000052c0},/* ┳ x-advance: 82.750000 */
{'@', 0x0000253b, 0x000052c0},/* ┻ x-advance: 82.750000 */
{'@', 0x0000252b, 0x000052c0},/* ┫ x-advance: 82.750000 */
{'@', 0x00002517, 0x000052c0},/* ┗ x-advance: 82.750000 */
{'@', 0x0000250f, 0x000052c0},/* ┏ x-advance: 82.750000 */
{'@', 0x00002503, 0x000052c0},/* ┃ x-advance: 82.750000 */
{'@', 0x00002501, 0x000052c0},/* ━ x-advance: 82.750000 */
{'@', 0x000023a2, 0x000044b9},/* ⎢ x-advance: 68.722656 */
{'@', 0x000023a5, 0x000044b9},/* ⎥ x-advance: 68.722656 */
};
#define CTX_FONT_regular 1
#endif
This diff is collapsed.
#include <math.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#define CTX_MIN_EDGE_LIST_SIZE 256
#define CTX_MAX_EDGE_LIST_SIZE 512
#define CTX_MIN_JOURNAL_SIZE 512
#define CTX_MAX_JOURNAL_SIZE 512 // Doesn't really get used - since
// we at the moment render synchronously
// from the data provided by core1
#define CTX_LIMIT_FORMATS 1
#define CTX_DITHER 1
#define CTX_ENABLE_RGB565_BYTESWAPPED 1
#define CTX_BITPACK_PACKER 0
#define CTX_COMPOSITING_GROUPS 0
#define CTX_RENDERSTREAM_STATIC 0
#define CTX_GRADIENT_CACHE 1
#define CTX_ENABLE_CLIP 1
#define CTX_BLOATY_FAST_PATHS 0
#define CTX_1BIT_CLIP 1
#define CTX_RASTERIZER_AA 3
#define CTX_RASTERIZER_FORCE_AA 1
#define CTX_SHAPE_CACHE 0
#define CTX_SHAPE_CACHE_DIM 16*18
#define CTX_SHAPE_CACHE_ENTRIES 128
#define CTX_RASTERIZER_MAX_CIRCLE_SEGMENTS 36
#define CTX_RASTERIZER 1
#define CTX_EVENTS 0
#define CTX_STRINGPOOL_SIZE 512
#define CTX_ENABLE_SHADOW_BLUR 0
#define CTX_FORMATTER 0
#define CTX_PARSER 0
#define CTX_FONTS_FROM_FILE 0
#define CTX_IMPLEMENTATION
#define _CTX_INTERNAL_FONT_ // defining this causes the internal font to be dropped
#include "ctx-font-regular.h" // font-regular contains the same outlines but more
// glyphs
#include "ctx.h"
This diff is collapsed.
includes = include_directories(
'./',
)
sources = files(
'ctx.c',
'ctx.h'
)
lib = static_library(
'ctx',
sources,
include_directories: includes,
dependencies: periphdriver,
c_args: ['-O3']
)
libctx = declare_dependency(
include_directories: includes,
link_with: lib,
)
...@@ -6,6 +6,7 @@ subdir('./vendor/Bosch/BMA400/') ...@@ -6,6 +6,7 @@ subdir('./vendor/Bosch/BMA400/')
subdir('./vendor/Maxim/MAX77650/') subdir('./vendor/Maxim/MAX77650/')
subdir('./vendor/Maxim/MAX86150/') subdir('./vendor/Maxim/MAX86150/')
subdir('./vendor/Maxim/rd117_mbed/') subdir('./vendor/Maxim/rd117_mbed/')
subdir('./ctx/')
subdir('./gfx/') subdir('./gfx/')
subdir('./FreeRTOS/') subdir('./FreeRTOS/')
......
...@@ -189,7 +189,7 @@ class Clock: ...@@ -189,7 +189,7 @@ class Clock:
def updateClock(self, disp, localtime): def updateClock(self, disp, localtime):
disp.clear(self.background_col) disp.clear(self.background_col)
disp.pixel(self.center[0] + self.offsetx, self.center[1], col=self.center_col) #disp.pixel(self.center[0] + self.offsetx, self.center[1], col=self.center_col)
hour_coords = self.circlePoint( hour_coords = self.circlePoint(
math.radians( math.radians(
(((localtime[3] % 12) / 12.0) if localtime[3] else 0) * 360 (((localtime[3] % 12) / 12.0) if localtime[3] else 0) * 360
...@@ -198,7 +198,7 @@ class Clock: ...@@ -198,7 +198,7 @@ class Clock:
) )
) )
minute_coords = self.circlePoint(math.radians(localtime[4] * 6 + 270)) minute_coords = self.circlePoint(math.radians(localtime[4] * 6 + 270))
second_coords = self.circlePoint(math.radians(localtime[5] * 6 + 270)) second_coords = self.circlePoint((math.radians(time.time_ms()%60000)/1000.0 * 6 + 270))
for i in range(60): for i in range(60):
degree = i * 6 + 90 degree = i * 6 + 90
...@@ -305,14 +305,11 @@ class Clock: ...@@ -305,14 +305,11 @@ class Clock:
vector = self.normVector(vector) vector = self.normVector(vector)
destination = self.addVector(source, self.multiplyVector(vector, length)) destination = self.addVector(source, self.multiplyVector(vector, length))
disp.line( disp.rgba(col[0]/255.0, col[1]/255.0, col[2]/255.0, 1.0)
round(source[0]) + self.offsetx, disp.move_to(source[0] + self.offsetx, source[1])
round(source[1]), disp.line_to(destination[0] + self.offsetx, destination[1])
round(destination[0]) + self.offsetx, disp.line_width(thickness)
round(destination[1]), disp.stroke()
col=col,
size=thickness,
)
def normVector(self, v): def normVector(self, v):
length = math.sqrt(sum([i ** 2 for i in v])) length = math.sqrt(sum([i ** 2 for i in v]))
......