Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/picosystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ namespace picosystem {
struct buffer_t {
int32_t w, h;
color_t *data;
bool alloc;

color_t *p(int32_t x, int32_t y) {
return data + (x + y * w);
}

~buffer_t() {
if (alloc) delete data;
}
};

struct voice_t {
Expand Down
13 changes: 11 additions & 2 deletions libraries/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ namespace picosystem {
buffer_t *b = new buffer_t();
b->w = w;
b->h = h;
b->data = data ? (color_t *)data : new color_t[w * h];
if (data)
{
b->data = (color_t *)data;
b->alloc = false;
}
else
{
b->data = new color_t[w * h]{};
b->alloc = true;
}
return b;
}

Expand Down Expand Up @@ -111,4 +120,4 @@ namespace picosystem {
return _fsin_lut[uint8_t((v * _2PI_LUTS) + 64)];
}

}
}
4 changes: 2 additions & 2 deletions micropython/examples/picosystem/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
def update(tick):
global view

if(pressed(RIGHT)):
if pressed(RIGHT):
view += 1

if(pressed(LEFT)):
if pressed(LEFT):
view -= 1

view %= view_count
Expand Down