mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Fix UI Drawing
This commit is contained in:
parent
91fd3e4302
commit
77d8c2d97e
3 changed files with 86 additions and 85 deletions
|
@ -1,10 +1,10 @@
|
|||
#include "display.h"
|
||||
#include "gpio.h"
|
||||
#include "spi_mode.h"
|
||||
#include "stmlib/system/system_clock.h"
|
||||
#include "stmlib/utils/random.h"
|
||||
#include <stm32f37x_conf.h>
|
||||
#include <u8g2.h>
|
||||
#include "spi_mode.h"
|
||||
|
||||
using namespace stmlib;
|
||||
|
||||
|
@ -64,7 +64,6 @@ void Display::Init()
|
|||
InitGLib();
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8x8_stm32_gpio_and_delay(U8X8_UNUSED u8x8_t* u8x8,
|
||||
U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int,
|
||||
U8X8_UNUSED void* arg_ptr)
|
||||
|
|
|
@ -56,12 +56,12 @@ void TIM2_IRQHandler(void)
|
|||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||
|
||||
// this will get called with 192 kHz (foof)
|
||||
// we want to reduce the amount of times the ui gets polled to 1kHz
|
||||
// we want to reduce the amount of times the ui gets polled to 500 Hz
|
||||
// which still is a lot (60fps would be enough tbh)
|
||||
|
||||
static uint8_t count = 0;
|
||||
count++;
|
||||
if (count % 192 == 0) {
|
||||
if (count % (192 * 2) == 0) {
|
||||
ui.Flush();
|
||||
count = 0;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const char part_names[4][2] = { "A", "B", "C", "D" };
|
|||
|
||||
void UI::Update()
|
||||
{
|
||||
|
||||
u8g2_ClearBuffer(display.u8g2());
|
||||
switch (current_menu) {
|
||||
case MENU_PART_1:
|
||||
case MENU_PART_2:
|
||||
|
@ -25,20 +25,22 @@ void UI::Update()
|
|||
|
||||
break;
|
||||
}
|
||||
display.Swap();
|
||||
}
|
||||
|
||||
void UI::DrawHeader()
|
||||
{
|
||||
u8g2_SetFont(display.u8g2(), u8g2_font_6x12_tf);
|
||||
for (int i = 0; i < PART_COUNT; i++) {
|
||||
u8g2_SetFontMode(display.u8g2(), 1);
|
||||
u8g2_SetDrawColor(display.u8g2(), 1);
|
||||
if (current_menu == i)
|
||||
u8g2_DrawBox(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT), HEADER_HEIGHT);
|
||||
u8g2_DrawBox(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT) - 1, HEADER_HEIGHT);
|
||||
else
|
||||
u8g2_DrawFrame(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT), HEADER_HEIGHT);
|
||||
u8g2_DrawFrame(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT), 0, (DISPLAY_WIDTH / PART_COUNT) - 1, HEADER_HEIGHT);
|
||||
|
||||
u8g2_SetDrawColor(display.u8g2(), 2);
|
||||
u8g2_DrawStr(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT) + 2, 2, part_names[i]);
|
||||
u8g2_DrawStr(display.u8g2(), i * (DISPLAY_WIDTH / PART_COUNT) + 5, 2 + 10, part_names[i]);
|
||||
u8g2_SetDrawColor(display.u8g2(), 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue