diff --git a/applications/coreglitch_demo_0/coreglitch_demo_0.c b/applications/coreglitch_demo_0/coreglitch_demo_0.c new file mode 100644 index 00000000..ee682378 --- /dev/null +++ b/applications/coreglitch_demo_0/coreglitch_demo_0.c @@ -0,0 +1,77 @@ +#include "flipper.h" +#include "u8g2/u8g2.h" + +extern TIM_HandleTypeDef htim5; + +void coreglitch_demo_0(void* p) { + FuriRecordSubscriber* log = get_default_log(); + + fuprintf(log, "coreglitch demo!\n"); + + // open record + FuriRecordSubscriber* fb_record = furi_open( + "u8g2_fb", false, false, NULL, NULL, NULL + ); + + if(fb_record == NULL) { + fuprintf(log, "[widget] cannot create fb record\n"); + furiac_exit(NULL); + } + + float notes[] = { + 0.0, + 330.0, + 220.0, + 0.0, + 110.0 + 55.0, + 440.0, + 330.0, + 55.0, + }; + + float scales[] = { + 1.0, + 1.5, + 0.75, + 0.8 + }; + + uint8_t cnt = 0; + + while(1) { + + for(size_t note_idx = 0; note_idx < 400; note_idx++) { + float scale = scales[((cnt + note_idx)/16) % 4]; + + float freq = notes[(note_idx + cnt / 2) % 8] * scale; + float width = 0.001 + 0.05 * (note_idx % (cnt/7 + 5)); + + if(note_idx % 8 == 0) { + freq = 0; + } + + // TODO get sound from FURI + pwm_set(width, freq, &htim5, TIM_CHANNEL_4); + // delay(1); + + cnt++; + + + u8g2_t* fb = furi_take(fb_record); + if(fb != NULL) { + u8g2_SetDrawColor(fb, 0); + u8g2_DrawBox(fb, 0, 0, 120, 30); + + u8g2_SetFont(fb, u8g2_font_6x10_mf); + u8g2_SetDrawColor(fb, 1); + u8g2_SetFontMode(fb, 1); + char buf[64]; + sprintf(buf, "freq: %d Hz", (uint32_t)freq); + u8g2_DrawStr(fb, 2 + width * 20, 12 + freq / 100, buf); + } + furi_commit(fb_record); + + delay(100); + } + } +} diff --git a/applications/display-u8g2/display-u8g2.c b/applications/display-u8g2/display-u8g2.c index 72f8a2b0..02c8d447 100644 --- a/applications/display-u8g2/display-u8g2.c +++ b/applications/display-u8g2/display-u8g2.c @@ -169,7 +169,7 @@ void display_u8g2(void* p) { while(1) { // wait for event - if(xSemaphoreTake(update, 1000) == pdTRUE) { + if(xSemaphoreTake(update, 10000) == pdTRUE) { HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET); u8g2_t* u8g2 = (u8g2_t*)furi_take(fb_record); diff --git a/applications/startup.h b/applications/startup.h index 59308b84..ebabc9c8 100644 --- a/applications/startup.h +++ b/applications/startup.h @@ -20,11 +20,15 @@ void display_u8g2(void* p); void u8g2_example(void* p); +void coreglitch_demo_0(void* p); + const FlipperStartupApp FLIPPER_STARTUP[] = { #ifndef TEST {.app = display_u8g2, .name = "display_u8g2"}, {.app = u8g2_example, .name = "u8g2_example"}, #endif + + // {.app = coreglitch_demo_0, .name = "coreglitch_demo_0"}, #ifdef TEST {.app = flipper_test_app, .name = "test app"}, diff --git a/target_f2/Makefile b/target_f2/Makefile index 27d95bb6..edc6c7be 100644 --- a/target_f2/Makefile +++ b/target_f2/Makefile @@ -171,6 +171,8 @@ endif # User application +C_SOURCES += ../applications/coreglitch_demo_0/coreglitch_demo_0.c + # Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here #######################################