Skip to content

Commit

Permalink
Merge pull request #3 from vladkorotnev/develop
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
vladkorotnev authored Jul 16, 2024
2 parents 2f0d77e + 0e55885 commit f0c06f1
Show file tree
Hide file tree
Showing 113 changed files with 4,266 additions and 427 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.pio
captures/
.vscode/c_cpp_properties.json
.env
/src/weather_icons/src
/src/weather_icons
.vscode/
Binary file added helper/chimes/bouken.mid
Binary file not shown.
Binary file added helper/chimes/gammapolisz.mid
Binary file not shown.
Binary file added helper/chimes/gentlejena.mid
Binary file not shown.
Binary file added helper/chimes/hishoku.mid
Binary file not shown.
Binary file added helper/chimes/like_the_wind.mid
Binary file not shown.
Binary file added helper/chimes/the_way.mid
Binary file not shown.
Binary file added helper/chimes/waiting_freqs.mid
Binary file not shown.
Binary file added helper/chimes/when_present_is_past.mid
Binary file not shown.
23 changes: 10 additions & 13 deletions helper/midi_to_chime.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,29 @@
mid = MidiFile(argv[1])
name = argv[2]

evts = [] # negative: delay in ms, positive: freq in hz
last_time = 0
evts = [] # of (freq in hz or 0, delay in ms)

for msg in mid:
if msg.type == "note_on" or msg.type == "note_off":
print(msg)
if msg.time > 0:
evts.append(int(-msg.time * 1000))
if msg.time > 0 and len(evts) > 0 and evts[-1][1] == 0:
evts[-1][1] = int(msg.time * 1000)
if msg.type == "note_on" and msg.velocity > 0:
if len(evts) > 0 and evts[-1] == 0:
# remove useless silence
evts[-1] = int(freq_note_converter.from_note_index(msg.note).freq)
else:
evts.append(int(freq_note_converter.from_note_index(msg.note).freq))
evts.append([int(freq_note_converter.from_note_index(msg.note).freq), 0])
else:
evts.append(0)
# note off
evts.append([0, 0])


print(evts)

print("static const melody_item_t "+name+"_data[] = {")
i = 0
while i < len(evts) - 1:
# assert evts[i] < 0
# assert evts[i+1] >= 0
print(" {"+str(evts[i])+", "+str(-evts[i+1])+"}, ")
i+=2
if evts[i][0] != 0 or evts[i][1] != 0:
print(" {"+str(evts[i][0])+", "+str(evts[i][1])+"}, ")
i+=1
print("};")

print("const melody_sequence_t "+name+" = MELODY_OF("+name+"_data);")
19 changes: 19 additions & 0 deletions include/app/alarm_editor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include <views/framework.h>
#include <sound/beeper.h>
#include <service/alarm.h>
#include "proto/navmenu.h"

class AppShimAlarmEditor: public ProtoShimNavMenu {
public:
AppShimAlarmEditor(Beeper*);
void pop_renderable(transition_type_t = TRANSITION_SLIDE_HORIZONTAL_RIGHT);

private:
class AlarmEditorView;
Beeper * beeper;

int current_editing_idx;
alarm_setting_t current_editing_setting;
AlarmEditorView * current_editor;
};
30 changes: 30 additions & 0 deletions include/app/alarming.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include <views/framework.h>
#include <graphics/framebuffer.h>
#include <sound/beeper.h>
#include <sensor/sensor.h>

void app_alarming_prepare(Beeper*);
void app_alarming_draw(FantaManipulator*);
void app_alarming_process();

class AppShimAlarming: public Renderable {
public:
AppShimAlarming(Beeper*b) {
beeper = b;
}

void prepare() {
app_alarming_prepare(beeper);
}

void render(FantaManipulator*fb) {
app_alarming_draw(fb);
}

void step() {
app_alarming_process();
}
private:
Beeper *beeper;
};
24 changes: 24 additions & 0 deletions include/app/idle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include <views/framework.h>
#include <graphics/framebuffer.h>
#include <sound/beeper.h>
#include <sensor/sensor.h>

void app_idle_prepare(SensorPool*, Beeper*);
void app_idle_draw(FantaManipulator*);
void app_idle_process();

class AppShimIdle: public Renderable {
public:
AppShimIdle(SensorPool*sp, Beeper*b) {
app_idle_prepare(sp, b);
}

void render(FantaManipulator*fb) {
app_idle_draw(fb);
}

void step() {
app_idle_process();
}
};
20 changes: 20 additions & 0 deletions include/app/menu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include "proto/navmenu.h"
#include <views/framework.h>
#include <graphics/framebuffer.h>
#include <sound/beeper.h>
#include <sensor/sensor.h>

class AppShimMenu: public ProtoShimNavMenu {
public:
AppShimMenu(Beeper*);

void prepare();
void step();

void pop_renderable(transition_type_t = TRANSITION_SLIDE_HORIZONTAL_RIGHT);

private:
Beeper * beeper;
TickType_t last_touch_time;
};
28 changes: 28 additions & 0 deletions include/app/proto/navigation_stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include <stack>
#include <views/framework.h>
#include <graphics/framebuffer.h>
#include <sound/beeper.h>
#include <sensor/sensor.h>

class ProtoShimNavigationStack: public Renderable {
public:
ProtoShimNavigationStack(Renderable* root);

void prepare();
void render(FantaManipulator*fb);
void step();

void push_submenu(ListView*);
void push_renderable(Renderable*, transition_type_t = TRANSITION_SLIDE_HORIZONTAL_LEFT);
virtual void pop_renderable(transition_type_t = TRANSITION_SLIDE_HORIZONTAL_RIGHT);

protected:
TransitionAnimationCoordinator * transition_coordinator;
TouchArrowOverlay * scroll_guidance;
Renderable* _root;
Renderable* _current_renderable;
void set_active_renderable(Renderable*, transition_type_t);
Renderable* current_renderable();
std::stack<Renderable*> back_stack;
};
10 changes: 10 additions & 0 deletions include/app/proto/navmenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once
#include "navigation_stack.h"

class ProtoShimNavMenu: public ProtoShimNavigationStack {
public:
ProtoShimNavMenu();
void prepare();
protected:
ListView* main_menu;
};
15 changes: 15 additions & 0 deletions include/app/timer_editor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once
#include <views/framework.h>
#include <views/common/dropping_digits.h>
#include <views/menu/melody_selection_item.h>
#include <app/proto/navigation_stack.h>
#include <sound/sequencer.h>

class AppShimTimerEditor: public ProtoShimNavigationStack, DroppingDigits {
public:
AppShimTimerEditor(Beeper *);
~AppShimTimerEditor();
private:
class TimerEditorMainScreen;
TimerEditorMainScreen * appRoot;
};
9 changes: 7 additions & 2 deletions include/devices/big_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

// Plasma Information System OS (not DOS, there's no disk in it!)
#define PRODUCT_NAME "PIS-OS"
#define PRODUCT_VERSION "1.2"
#define PRODUCT_VERSION "2.0"

// ---- Connection to DISP BOARD ----

const gpio_num_t HWCONF_PLASMA_DATABUS_GPIOS[] = {
GPIO_NUM_15,
GPIO_NUM_2,
Expand All @@ -29,6 +28,9 @@ const gpio_num_t HWCONF_PLASMA_RESET_GPIO = GPIO_NUM_21;
const gpio_num_t HWCONF_PLASMA_BRIGHT_GPIO = GPIO_NUM_22;
const gpio_num_t HWCONF_PLASMA_SHOW_GPIO = GPIO_NUM_23;

#define HWCONF_DISPLAY_WIDTH_PX 101
#define HWCONF_DISPLAY_HEIGHT_PX 16

// ---- Connection to HV Board ----
const gpio_num_t HWCONF_PLASMA_HV_EN_GPIO = GPIO_NUM_13;

Expand All @@ -43,3 +45,6 @@ const gpio_num_t HWCONF_LIGHTSENSE_GPIO = GPIO_NUM_35;
// ---- Connection of NOSE BOARD ----
const gpio_num_t HWCONF_I2C_SDA_GPIO = GPIO_NUM_26;
const gpio_num_t HWCONF_I2C_SCL_GPIO = GPIO_NUM_25;

// ---- TBD: Connection of buttons ----
// Free GPIOS: 36, 39, 34, 27
18 changes: 17 additions & 1 deletion include/devices/smol_clock.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once

#include <hal/gpio_hal.h>
#include <input/touch_plane.h>

#define HAS_OUTPUT_WS0010
#define HAS_TEMP_SENSOR
#define HAS_TOUCH_PLANE

// Plasma Information System OS (not DOS, there's no disk in it!)
#define PRODUCT_NAME "microPIS-OS"
#define PRODUCT_VERSION "1.0"
#define PRODUCT_VERSION "2.0"

// ---- Connection to beeper ----
const gpio_num_t HWCONF_BEEPER_GPIO = GPIO_NUM_12;
Expand All @@ -30,3 +32,17 @@ const gpio_num_t HWCONF_WS0010_DATABUS_GPIOS[] = {
};
const gpio_num_t HWCONF_WS0010_RS_GPIO = GPIO_NUM_19;
const gpio_num_t HWCONF_WS0010_EN_GPIO = GPIO_NUM_18;

#define HWCONF_DISPLAY_WIDTH_PX 100
#define HWCONF_DISPLAY_HEIGHT_PX 16

// ---- Connection to touch plane ----
const touch_plane_definition_t HWCONF_TOUCH_PLANE = {
// Screen panel
{/*GPIO_NUM_32*/ TOUCH_PAD_NUM9, {.key = KEY_RIGHT, .press_threshold = 7, .release_threshold = -3}},
{/*GPIO_NUM_33*/ TOUCH_PAD_NUM8, {.key = KEY_UP, .press_threshold = 7, .release_threshold = -2}},
{/*GPIO_NUM_27*/ TOUCH_PAD_NUM7, {.key = KEY_DOWN, .press_threshold = 7, .release_threshold = -2}},
{/*GPIO_NUM_14*/ TOUCH_PAD_NUM6, {.key = KEY_LEFT, .press_threshold = 7, .release_threshold = -2}},
// Top of case
// {/*GPIO_NUM_13*/ TOUCH_PAD_NUM4, KEY_HEADPAT},
};
27 changes: 27 additions & 0 deletions include/display/display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include <device_config.h>

#if HAS(OUTPUT_MD_PLASMA)
#include <display/md_plasma.h>
#elif HAS(OUTPUT_WS0010)
#include <display/ws0010.h>
#endif

#if HAS(OUTPUT_MD_PLASMA)
static MorioDenkiPlasmaDriver display_driver(
HWCONF_PLASMA_DATABUS_GPIOS,
HWCONF_PLASMA_CLK_GPIO,
HWCONF_PLASMA_RESET_GPIO,
HWCONF_PLASMA_BRIGHT_GPIO,
HWCONF_PLASMA_SHOW_GPIO,
HWCONF_PLASMA_HV_EN_GPIO
);
#elif HAS(OUTPUT_WS0010)
static Ws0010OledDriver display_driver(
HWCONF_WS0010_DATABUS_GPIOS,
HWCONF_WS0010_RS_GPIO,
HWCONF_WS0010_EN_GPIO
);
#else
#error Output type not selected
#endif
13 changes: 9 additions & 4 deletions include/graphics/fanta_manipulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,28 @@ class FantaManipulator {
/// @param y Y position of the graphic to be placed
/// @param w Width of the graphic to be placed
/// @param h Height of the graphic to be placed
void put_fanta(const fanta_buffer_t, int x, int y, int w, int h);
/// @param mask Mask for the graphic (can be null)
void put_fanta(const fanta_buffer_t, int x, int y, int w, int h, const fanta_buffer_t mask = nullptr, bool invert = false);
/// @brief Place a sprite at a specified position of the Fanta buffer
void put_sprite(const sprite_t*, int x, int y);
void put_sprite(const sprite_t*, int x, int y, bool invert = false);
/// @brief Place a glyph from a font at a specified position of the Fanta buffer
/// @param font Font to look up the glyph in
/// @param glyph Glyph code to place
/// @param x X position for the glyph
/// @param y Y position for the glyph
void put_glyph(const font_definition_t * font, const unsigned char glyph, int x, int y);
void put_glyph(const font_definition_t * font, const unsigned char glyph, int x, int y, bool invert = false);
/// @brief Draw a string with the specified font at the specified position in the Fanta buffer. Does not do any line wrapping.
void put_string(const font_definition_t *, const char *, int x, int y);
void put_string(const font_definition_t *, const char *, int x, int y, bool invert = false);
/// @brief Offset the contents of the buffer
/// @param dx Horizontal offset. Negative is to the left.
/// @param dy Vertical offset. Negative is to the top.
void scroll(int dx, int dy);
/// @brief Invert all pixels of the buffer
void invert();
/// @brief Draws a line using Bresenham's algorithm
void line(int x1, int y1, int x2, int y2);
/// @brief Draws a rectangle
void rect(int x1, int y1, int x2, int y2, bool fill);

/// @brief Get the width of the buffer in pixels
int get_width();
Expand Down
9 changes: 5 additions & 4 deletions include/graphics/framebuffer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <device_config.h>
#include <graphics/display_driver.h>
#include "fanta_manipulator.h"
#include <freertos/FreeRTOS.h>
Expand All @@ -8,10 +9,10 @@
/// @brief A framebuffer for driving the plasma display
class DisplayFramebuffer {
public:
static const int width = 101;
static const int height = 16;
static const int width = HWCONF_DISPLAY_WIDTH_PX;
static const int height = HWCONF_DISPLAY_HEIGHT_PX;
/// @brief Size of the backing buffer in bytes
static const size_t PDFB_BUFFER_SIZE = width * (height / 8);
static const size_t BUFFER_SIZE = width * ceil(height / 8.0);

DisplayFramebuffer(DisplayDriver * display);
~DisplayFramebuffer();
Expand All @@ -34,7 +35,7 @@ class DisplayFramebuffer {
FantaManipulator * manipulate();

private:
uint8_t buffer[PDFB_BUFFER_SIZE];
uint8_t buffer[BUFFER_SIZE];
SemaphoreHandle_t buffer_semaphore;
EventGroupHandle_t vsync_group;
TaskHandle_t hTask;
Expand Down
2 changes: 2 additions & 0 deletions include/graphics/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
typedef struct sprite {
uint8_t width, height;
const uint8_t* data;
const uint8_t* mask;
} sprite_t;

/// @brief An animated sprite.
Expand Down Expand Up @@ -40,6 +41,7 @@ typedef uint8_t* fanta_buffer_t;
/// @brief Convert a horizontally laid out, LSB aligned sprite bitmap of an arbitrary size, to a vertically aligned 16-bit-per-column Fanta buffer.
/// @note Unused pixels are filled with 0's. Transparency et al. should be handled by the drawing code.
extern fanta_buffer_t sprite_to_fanta(const sprite_t*);
extern fanta_buffer_t mask_to_fanta(const sprite_t*);
/// @brief Offset a raw Fanta buffer vertically. Negative is towards the top.
extern void fanta_offset_y(fanta_buffer_t,int,size_t);

Expand Down
8 changes: 0 additions & 8 deletions include/idle.h

This file was deleted.

Loading

0 comments on commit f0c06f1

Please sign in to comment.