Skip to content

Commit

Permalink
file viewer, midi player working, some ugly changes, buffered drawing…
Browse files Browse the repository at this point in the history
… for faster blitting, graphing applications, new stable release!
  • Loading branch information
Gabriel committed Jan 13, 2019
1 parent 7511fa1 commit 23e41f3
Show file tree
Hide file tree
Showing 75 changed files with 4,850 additions and 2,954 deletions.
11 changes: 7 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ When I was developing alternative firmware for DS203, I was trying to design som

#### Installation

Go to release section on top of this page, download *system.hex*. Power on the LA104 while holding first button. Connect the device using USB cable with your computer. New disk drive should appear, copy the *system.hex* file there. The disk should disconnect and reconnect shortly after the upload was finished. If you are lucky, you will see *manager.rdy* on the disk. Turn the unit off and on and copy remaining files from zip archive *approot.zip* to your device. After power cycle a gui should appear.
Go to release section on top of this page, download *system.hex*. Power on the LA104 while holding first button. Connect the device using USB cable with your computer. New disk drive should appear, copy the *system.hex* file there. The disk should disconnect and reconnect shortly after the upload was finished. If you are lucky, you will see *manager.rdy* on the disk. Turn the unit off and on and copy remaining files from zip archive *approot.zip* to your device. After power cycle a gui should appear. If the file system does not appear stable, you can format it using [tools/dfuload](tools/dfuload/format.sh) script.


#### News
Expand Down Expand Up @@ -135,16 +135,18 @@ Connect your midi keyboard with two wires (3V and P1 through 100-330 ohm resisto
- automated generation of app root & including icons (50%, icons tbd)
- universal IR remote control app (80% done, samsung compatible)
- One wire temperature sensor grapher (90% done, drawing temperature chart of up to 8 sensors)
- Analog oscilloscope using PCF8591 (90% done)
- Test signal generator running in background for testing of logic analyser app (80% done)
- swiss army knife for hardware engineers - package of applications that can talk to popular electronic devices (some samples are already there) and monitor any digital buses (logic analyser)
- DCF77 decoding application with visualization
- manual & text reader app (100%)
- solve problem how to pass file as argument to app run through gui shell (100% only using file manager)

#### In progress
- working directory & relative paths
- solve problem how to pass file as argument to app run through gui shell
- usb apps & screenshotter do not work reliably after last changes (partially fixed, needs more testing)
- advanced IR remote control (record & play)
- manual & text reader app
- add manuals to all folders with brief description what which program does
- ESP8266 AP webserver using AT commands

#### TODO list
- SIMCOM test app
Expand Down Expand Up @@ -180,6 +182,7 @@ Connect your midi keyboard with two wires (3V and P1 through 100-330 ohm resisto
#### Abandoned ideas
- remote control using ESP or BLE - possible to attach to UART0? (not possible, use USB CDC instead)
- finish GIF loading, or consider other image formats (PCX, LBM, BMP?) - BMP won
- working directory & relative paths (not important now)

#### Hardware improvement suggestions
- add test pads for UART0 on PCB, this would allow various hardware mods
Expand Down
7 changes: 6 additions & 1 deletion system/apps/test21_midiplay/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,12 @@ int _main(void)
bool loaded{false};

char* fileName = BIOS::OS::GetArgument();
if (strlen(fileName) == 0)

fileName = strstr(fileName, " ");
if (fileName)
fileName++;

if (!fileName || strlen(fileName) == 0)
{
strcpy(strDisplay, "No midi loaded, use F4 in manager");
} else
Expand Down
3 changes: 0 additions & 3 deletions system/apps/test33_temper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ int _main(void)
if (key != BIOS::KEY::None)
app.WindowMessage(CWnd::WmKey, key);
app.WindowMessage(CWnd::WmTick);

if (BIOS::OS::GetArgument()[0])
break;
}

app.Destroy();
Expand Down
89 changes: 89 additions & 0 deletions system/apps/test34_scope/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0025 NEW)
project(LA140_emulator)

set(CMAKE_SUPPRESS_REGENERATION true)
set (CMAKE_CXX_STANDARD 17)

# call "brew install sdl2"

if (ARM)
include_directories("../os_library/include")
endif()

if (DESKTOP)
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
include_directories("include/")

file(GLOB main_src
"source/sdlmain.cpp"
"include/library.h"
)

file(GLOB bios_src
"source/bios/*.cpp"
"source/bios/*.h"
)

file(GLOB framework_src
"source/framework/*.cpp"
"source/framework/*.h"
)

file(GLOB gui_src
"source/gui/*.cpp"
"source/gui/*.h"
)
endif()

if (ARM)
file(GLOB main_src
"../os_host/source/framework/Wnd.cpp"
)

file(GLOB linker_script
"../apps/test34_scope/app.lds"
)
endif()

file(GLOB application_src
"../apps/test34_scope/*.cpp"
"../apps/test34_scope/*.h"
)

file(GLOB application_graph_src
"../apps/test34_scope/graph/*.cpp"
"../apps/test34_scope/graph/*.h"
)

file(GLOB application_sensor_src
"../apps/test34_scope/sensor/*.cpp"
"../apps/test34_scope/sensor/*.h"
)

if (DESKTOP)
source_group("source\\main" FILES "source/sdlmain.cpp")
source_group("source\\bios" FILES ${bios_src})
source_group("source\\framework" FILES ${framework_src})
source_group("source\\gui" FILES ${gui_src})
endif()

source_group("application" FILES ${application_src})
source_group("application\\graph" FILES ${application_graph_src})
source_group("application\\sensor" FILES ${application_sensor_src})
source_group("include" FILES "include/library.h")

add_executable(application ${main_src} ${bios_src} ${framework_src} ${gui_src} ${application_src} ${application_graph_src} ${application_sensor_src})

if (ARM)
target_link_libraries(application m)
target_link_libraries(application bios)
set_target_properties(application PROPERTIES LINK_DEPENDS ${linker_script})
set_target_properties(application PROPERTIES LINK_FLAGS "-T ${linker_script}")
endif()

target_link_libraries(application ${SDL2_LIBRARIES})

install(TARGETS application DESTINATION bin)
33 changes: 33 additions & 0 deletions system/apps/test34_scope/app.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
MEMORY
{
rom (rx) : ORIGIN = 0x08020000, LENGTH = 20K
ram (rwx) : ORIGIN = 0x20007000, LENGTH = 8K
null (rwx): ORIGIN = 0x00001000, LENGTH = 4K
}

/* _estack = ORIGIN(ram)+LENGTH(ram)-0x100; */

SECTIONS
{
.text : {
*(.entry)
*(.text*) /* Program code */
*(.rodata*) /* Read only data */
} >rom

.data : {
*(.data) /* Data memory */
} >ram AT >rom

.bss : {
*(.bss*) /* Zero-filled run time allocate data memory */
} >ram

.rel.plt : { *(.rel.plt) } > rom
.plt : { *(.plt) } > rom
.got : { *(.got.plt) *(.got) } > ram /* relocation fixed by memory write! */
.dynsym : { *(.dynsym) } > null
.dynstr : { *(.dynstr) } > null

}

16 changes: 16 additions & 0 deletions system/apps/test34_scope/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

export PATH="/Users/gabrielvalky/Downloads/gcc-arm-none-eabi-7-2018-q2-update/bin/":"$PATH"
mkdir -p build
cd build

arm-none-eabi-g++ -Wall -Os -Werror -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -fno-exceptions -fno-rtti -fno-threadsafe-statics -Wno-psabi -MD -c ../main.cpp ../../../os_host/source/framework/Wnd.cpp -I../../../os_library/include/
#arm-none-eabi-gcc -fPIC -mcpu=cortex-m3 -mthumb -o output.elf -nostartfiles -Wl,--unresolved-symbols=ignore-all -T ../app.lds ./main.o
arm-none-eabi-gcc -fPIC -mcpu=cortex-m3 -mthumb -o output.elf -nostartfiles -T ../app.lds ./main.o ./Wnd.o -lbios -lm -L../../../os_library/build

arm-none-eabi-objdump -d -S output.elf > output.asm

find . -type f -name '*.o' -delete
find . -type f -name '*.d' -delete

../../../../tools/elfstrip/elfstrip output.elf 34scope.elf
5 changes: 5 additions & 0 deletions system/apps/test34_scope/cp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdir fs
sudo mount -t msdos /dev/disk2 fs
cp build/34scope.elf fs/34scope.elf
sudo umount fs
rmdir fs
152 changes: 152 additions & 0 deletions system/apps/test34_scope/graph/axis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
class CXAxis : public CWnd
{
friend class CYAxis;

protected:
static int nicenumber(int n)
{
int mantisa = n, exponent = 1;
while (mantisa > 10)
{
exponent *= 10;
mantisa /= 10;
}

if (mantisa >= 5)
mantisa = 5;
else
if (mantisa >= 2)
mantisa = 2;
else
mantisa = 1;

return mantisa * exponent;
}

virtual void FormatNumber(char* buf, int i)
{
if (i<1000)
{
sprintf(buf, "%d", i);
return;
}

if (i<1000000)
{
sprintf(buf, "%dk", i/1000);
return;
}

sprintf(buf, "%dM", i/1000000);
}

virtual int reconstruct(int i)
{
return i;
}

virtual void Redraw(int value, int origValue)
{
int step = nicenumber(value/2);
//BIOS::DBG::Print("orig=%d max=%d step=%d\n", origValue, value, step);
CRect rcDeflated(m_rcClient);
rcDeflated.Deflate(2, 0, 2, 0);
BIOS::LCD::Bar(rcDeflated, RGB565(b0b0b0));

for (int _i=0; _i<=value; _i += step)
{
int i = reconstruct(_i);
if (i>origValue)
break;

int x = m_rcClient.left + m_rcClient.Width()*i/origValue;
char formatted[16];
FormatNumber(formatted, _i);
int width = strlen(formatted)*8;

int tx = x;
if (tx - width/2 < rcDeflated.left)
tx = m_rcClient.left + 2 + width/2;

if (tx-width/2+width > rcDeflated.right)
tx = m_rcClient.right - 2 - width/2;

BIOS::LCD::Print(tx - width/2, m_rcClient.bottom-14, RGB565(404040), RGB565(b0b0b0), formatted);

if (x >= rcDeflated.left && x < rcDeflated.right)
BIOS::LCD::Bar(x, m_rcClient.top, x+1, m_rcClient.top+3, RGB565(ffffff));
}
}

public:
virtual void Update(int value)
{
Redraw(value, value);
}
};

class CYAxis : public CWnd
{
Range mRange;

protected:
virtual int forward(int i)
{
return i;
}

virtual int backward(int i)
{
return i;
}

virtual void FormatNumber(char* buf, int i)
{
sprintf(buf, "%d", i);
}

public:
virtual void OnPaint()
{
}

void Update(const Range& range)
{
if (mRange == range)
return;
mRange = range;

BIOS::LCD::Bar(m_rcClient, RGB565(b0b0b0));

auto drawTick = [&](int i)
{
int y = m_rcClient.bottom - (backward(i)-range.mMin)*m_rcClient.Height()/(range.mMax-range.mMin);
if (y < m_rcClient.bottom)
BIOS::LCD::Bar(m_rcClient.right-2, y, m_rcClient.right, y+1, RGB565(ffffff));

char buffer[16];
FormatNumber(buffer, i);

int ty = y-6;
if (ty<m_rcClient.top)
ty = m_rcClient.top;
if (ty+14>m_rcClient.bottom)
ty = m_rcClient.bottom-14;

BIOS::LCD::Print(m_rcClient.right - strlen(buffer)*8-3, ty, RGB565(404040), RGB565(b0b0b0), buffer);
};

int rangeMaxModified = forward(range.mMax/2);
int step = CXAxis::nicenumber(rangeMaxModified);
int total = std::max<>(forward(range.mMax), forward(-range.mMin));

for (int i=0; i<total; i += step)
{
if (i < range.mMax)
drawTick(i);
// if (i > 0 && -i > range.mMin)
// drawTick(-i);
}
}
};

Loading

0 comments on commit 23e41f3

Please sign in to comment.