!8 refactor wave_ctrl & support MCU basicly.

Merge pull request !8 from idea4good/dev
This commit is contained in:
idea4good 2019-01-09 11:23:42 +08:00
parent 6cdcd25436
commit 144993f2d7
15 changed files with 781 additions and 110 deletions

5
.gitignore vendored
View File

@ -38,3 +38,8 @@ Makefile
libcore.a
libgui.a
# Keil
GuiLite.uvguix.*
GuiLite.uvoptx
Objects

472
GuiLite.uvprojx Normal file
View File

@ -0,0 +1,472 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>GuiLite</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>ARMCM3</Device>
<Vendor>ARM</Vendor>
<PackID>ARM.CMSIS.5.4.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IROM(0x00000000,0x00040000) CPUTYPE("Cortex-M3") CLOCK(12000000) ESEL ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000)</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:ARMCM3$Device\ARM\ARMCM3\Include\ARMCM3.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile></SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>GuiLite</OutputName>
<CreateExecutable>0</CreateExecutable>
<CreateLib>1</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\Listings\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> -MPU</SimDllArguments>
<SimDlgDll>DCM.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM3</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> -MPU</TargetDllArguments>
<TargetDlgDll>TCM.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>-1</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3></Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M3"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>0</useUlib>
<EndSel>1</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>1</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>1</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x20000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x20000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>0</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>0</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>0</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>1</v6Lang>
<v6LangP>1</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath>.\core</IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>0</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x00000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>core</GroupName>
<Files>
<File>
<FileName>bitmap.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\bitmap.cpp</FilePath>
</File>
<File>
<FileName>cmd_target.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\cmd_target.cpp</FilePath>
</File>
<File>
<FileName>display.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\display.cpp</FilePath>
</File>
<File>
<FileName>rect.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\rect.cpp</FilePath>
</File>
<File>
<FileName>surface.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\surface.cpp</FilePath>
</File>
<File>
<FileName>wave_buffer.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\wave_buffer.cpp</FilePath>
</File>
<File>
<FileName>wave_ctrl.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\wave_ctrl.cpp</FilePath>
</File>
<File>
<FileName>wnd.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\wnd.cpp</FilePath>
</File>
<File>
<FileName>word.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\word.cpp</FilePath>
</File>
<File>
<FileName>api_none.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\adapter\api_none.cpp</FilePath>
</File>
<File>
<FileName>msg_none.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\core\src\adapter\msg_none.cpp</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>gui</GroupName>
<Files>
<File>
<FileName>button.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\gui\src\button.cpp</FilePath>
</File>
<File>
<FileName>label.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\gui\src\label.cpp</FilePath>
</File>
<File>
<FileName>my_resource.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\gui\src\my_resource.cpp</FilePath>
</File>
</Files>
</Group>
</Groups>
</Target>
</Targets>
<RTE>
<apis/>
<components/>
<files/>
</RTE>
</Project>

View File

@ -12,6 +12,7 @@ public:
c_display(void* phy_fb, unsigned int display_width, unsigned int display_height,
unsigned int surface_width, unsigned int surface_height,
unsigned int color_bytes, unsigned int surface_cnt);
c_display(unsigned int display_width, unsigned int display_height, unsigned int color_bytes, EXTERNAL_GFX_OP* gfx_op);
c_surface* alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder);
int merge_surface(c_surface* s1, c_surface* s2, int x0, int x1, int y0, int y2, int offset);
unsigned int get_width() { return m_width; }

View File

@ -70,4 +70,22 @@ class c_surface_16bits : public c_surface {
protected:
virtual void set_pixel(int x, int y, unsigned int rgb);
};
struct EXTERNAL_GFX_OP
{
void (*draw_pixel)(int x, int y, unsigned int rgb);
void (*fill_rect)(int x0, int y0, int x1, int y1, unsigned int rgb);
};
class c_surface_mcu : public c_surface {
friend class c_display;
c_surface_mcu(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op);
virtual void draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order);
virtual void fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order);
virtual void fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb);
virtual unsigned int get_pixel(int x, int y, unsigned int z_order);
protected:
virtual void set_pixel(int x, int y, unsigned int rgb);
private:
struct EXTERNAL_GFX_OP* m_gfx_op;
};
#endif

View File

@ -27,13 +27,13 @@ public:
void set_wave_name(char* wave_name){ m_wave_name = wave_name;}
void set_wave_unit(char* wave_unit){ m_wave_unit = wave_unit;}
void set_wave_name_font_type(const FONT_INFO* wave_name_font_type){ m_wave_name_font_type = wave_name_font_type;}
void set_wave_unit_font_type(const FONT_INFO* wave_unit_font_type){ m_wave_unit_font_type = wave_unit_font_type;}
void set_wave_name_font(const FONT_INFO* wave_name_font_type){ m_wave_name_font = wave_name_font_type;}
void set_wave_unit_font(const FONT_INFO* wave_unit_font_type){ m_wave_unit_font = wave_unit_font_type;}
void set_wave_name_color(unsigned int wave_name_color){ m_wave_name_color = wave_name_color;}
void set_wave_unit_color(unsigned int wave_unit_color){ m_wave_unit_color = wave_unit_color;}
void set_wave_color(unsigned int color){ m_wave_color = color;}
void set_wave_sample_rate(unsigned int rate);//speed = module sample rate
void set_wave_in_out_rate(unsigned int data_rate, unsigned int refresh_rate);
void set_wave_speed(unsigned int speed);
void set_max_min_base(short max_data, short min_data, short data_base);
@ -53,8 +53,8 @@ protected:
char* m_wave_name;
char* m_wave_unit;
const FONT_INFO* m_wave_name_font_type;
const FONT_INFO* m_wave_unit_font_type;
const FONT_INFO* m_wave_name_font;
const FONT_INFO* m_wave_unit_font;
unsigned int m_wave_name_color;
unsigned int m_wave_unit_color;
@ -77,7 +77,8 @@ private:
unsigned int* m_bg_fb; //background frame buffer, could be used to draw scale line.
int m_wave_cursor;
int m_wave_speed; //pixels per refresh
int m_wave_sample_rate;
unsigned int m_wave_data_rate; //data sample rate
unsigned int m_wave_refresh_rate;//refresh cycle in millisecond
unsigned char m_frame_len_map[64];
unsigned char m_frame_len_map_index;
};

View File

@ -11,7 +11,7 @@ public:
static void draw_value_in_rect(c_surface* surface, int z_order, int value, int dot_position, c_rect rect, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color, unsigned int align_type = ALIGN_LEFT);
static void value_2_string(int value, int dot_position, char* buf, int len);
static int get_str_pixel_length(const char *s, const FONT_INFO* font);
static int get_str_size(const char *s, const FONT_INFO* font, int& width, int& height);
private:
static int draw_single_char(c_surface* surface, int z_order, unsigned int utf8_code, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color);
static void draw_lattice(c_surface* surface, int z_order, int x, int y, int width, int height, const unsigned char* p_data, unsigned int font_color, unsigned int bg_color);

View File

@ -0,0 +1,84 @@
#include "../../core_include/api.h"
#include <stdio.h>
static void(*do_assert)(const char* file, int line);
static void(*do_log_out)(const char* log);
void register_debug_function(void(*my_assert)(const char* file, int line), void(*my_log_out)(const char* log))
{
do_assert = my_assert;
do_log_out = my_log_out;
}
void _assert(const char* file, int line)
{
if(do_assert)
{
do_assert(file, line);
}
else
{
printf("assert@ file:%s, line:%d\n", file, line);
}
}
void log_out(const char* log)
{
if (do_log_out)
{
do_log_out(log);
}
else
{
printf(log);
fflush(stdout);
}
}
long get_time_in_second()
{
return 0;
}
T_TIME second_to_day(long second)
{
T_TIME ret = {0};
return ret;
}
T_TIME get_time()
{
T_TIME ret = {0};
return ret;
}
void start_real_timer(void (*func)(void* arg))
{
log_out("Not support now");
}
void register_timer(int milli_second, void func(void* ptmr, void* parg))
{
log_out("Not support now");
}
unsigned int get_cur_thread_id()
{
log_out("Not support now");
return 0;
}
void create_thread(unsigned long* thread_id, void* attr, void *(*start_routine) (void *), void* arg)
{
log_out("Not support now");
}
void thread_sleep(unsigned int milli_seconds)
{
log_out("Not support now");
}
int build_bmp(const char *filename, unsigned int width, unsigned int height, unsigned char *data)
{
log_out("Not support now");
return 0;
}

View File

@ -1,11 +1,6 @@
#include "../../core_include/api.h"
#include "../../core_include/rect.h"
#include "../../core_include/surface.h"
#include "../../core_include/display.h"
#include "../../core_include/msg.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>

View File

@ -0,0 +1,56 @@
#include "../../core_include/api.h"
#include "../../core_include/msg.h"
c_fifo::c_fifo()
{
m_head = m_tail = 0;
m_read_sem = m_write_mutex = NULL;
}
int c_fifo::read(void* buf, int len)
{
unsigned char* pbuf = (unsigned char*)buf;
int i = 0;
while(i < len)
{
if (m_tail == m_head)
{//empty
continue;
}
*pbuf++ = m_buf[m_head];
m_head = (m_head + 1) % FIFO_BUFFER_LEN;
i++;
}
if(i != len)
{
ASSERT(FALSE);
}
return i;
}
int c_fifo::write(void* buf, int len)
{
unsigned char* pbuf = (unsigned char*)buf;
int i = 0;
int tail = m_tail;
while(i < len)
{
if ((m_tail + 1) % FIFO_BUFFER_LEN == m_head)
{//full, clear data has been written;
m_tail = tail;
log_out("Warning: fifo full\n");
return 0;
}
m_buf[m_tail] = *pbuf++;
m_tail = (m_tail + 1) % FIFO_BUFFER_LEN;
i++;
}
if(i != len)
{
ASSERT(FALSE);
}
return i;
}

View File

@ -1,7 +1,4 @@
#include "../../core_include/api.h"
#include "../../core_include/rect.h"
#include "../../core_include/surface.h"
#include "../../core_include/display.h"
#include "../../core_include/msg.h"
#include <windows.h>

View File

@ -37,6 +37,15 @@ c_display::c_display(void* phy_fb, unsigned int display_width, unsigned int disp
}
}
c_display::c_display(unsigned int display_width, unsigned int display_height, unsigned int color_bytes, EXTERNAL_GFX_OP* gfx_op)
{
m_width = display_width;
m_height = display_height;
m_surface_cnt = 1;
m_phy_fb = NULL;
m_surface_group[0] = new c_surface_mcu(this, display_width, display_height, color_bytes, gfx_op);
}
c_surface* c_display::alloc_surface(void* usr, Z_ORDER_LEVEL max_zorder)
{
int i = 0;

View File

@ -568,3 +568,50 @@ unsigned int c_surface_16bits::get_pixel(int x, int y, unsigned int z_order)
return GL_RGB_16_to_32(((unsigned short*)(m_frame_layers[z_order].fb))[y * m_width + x]);
}
//////////////////////////////////////////////////////////////////////////////////////
c_surface_mcu::c_surface_mcu(c_display* display, unsigned int width, unsigned int height, unsigned int color_bytes, struct EXTERNAL_GFX_OP* gfx_op) :
c_surface(display, width, height, color_bytes)
{
m_gfx_op = gfx_op;
}
void c_surface_mcu::draw_pixel(int x, int y, unsigned int rgb, unsigned int z_order)
{
if (x >= m_width || y >= m_height || x < 0 || y < 0)
{
return;
}
if (m_gfx_op && m_gfx_op->draw_pixel)
{
m_gfx_op->draw_pixel(x, y, rgb);
}
}
void c_surface_mcu::fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, unsigned int z_order)
{
if (m_gfx_op && m_gfx_op->fill_rect)
{
return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb);
}
for (; y0 <= y1; y0++)
{
draw_hline(x0, x1, y0, rgb, z_order);
}
}
void c_surface_mcu::fill_rect_on_fb(int x0, int y0, int x1, int y1, unsigned int rgb)
{//Not support
ASSERT(FALSE);
}
unsigned int c_surface_mcu::get_pixel(int x, int y, unsigned int z_order)
{//Not support
return 0;
}
void c_surface_mcu::set_pixel(int x, int y, unsigned int rgb)
{//Not support
ASSERT(FALSE);
}

View File

@ -23,13 +23,14 @@ c_wave_ctrl::c_wave_ctrl()
{
m_wave = NULL;
m_bg_fb = NULL;
m_wave_name_font_type = m_wave_unit_font_type = NULL;
m_wave_name_font = m_wave_unit_font = NULL;
m_wave_name = m_wave_unit = 0;
m_max_data = 500;
m_min_data = 0;
m_pivot_data = 250;
m_wave_speed = 4;
m_wave_sample_rate = 0;
m_wave_data_rate = 0;
m_wave_refresh_rate = 1000;
m_gain = ZOOM_100;
m_frame_len_map_index = 0;
@ -63,19 +64,16 @@ void c_wave_ctrl::set_wave_gain(E_WAVE_GAIN gain)
m_gain = gain;
}
void c_wave_ctrl::set_wave_sample_rate(unsigned int rate)
void c_wave_ctrl::set_wave_in_out_rate(unsigned int data_rate, unsigned int refresh_rate)
{
if(rate > 500)
{
ASSERT(FALSE);
}
m_wave_sample_rate = rate;
int read_times_per_second = m_wave_speed * 1000 / REAL_TIME_TASK_CYCLE_MS;
m_wave_data_rate = data_rate;
m_wave_refresh_rate = refresh_rate;
int read_times_per_second = m_wave_speed * 1000 / m_wave_refresh_rate;
memset(m_frame_len_map, 0, sizeof(m_frame_len_map));
for (unsigned int i = 1; i < sizeof(m_frame_len_map) + 1; i++)
{
m_frame_len_map[i-1] = rate * i / read_times_per_second - rate * (i-1) / read_times_per_second;
m_frame_len_map[i-1] = data_rate * i / read_times_per_second - data_rate * (i-1) / read_times_per_second;
}
m_frame_len_map_index = 0;
}
@ -94,7 +92,7 @@ void c_wave_ctrl::set_wave_speed(unsigned int speed)
ASSERT(FALSE);
break;
}
set_wave_sample_rate(m_wave_sample_rate);
set_wave_in_out_rate(m_wave_data_rate, m_wave_refresh_rate);
}
void c_wave_ctrl::clear_data()
@ -234,9 +232,9 @@ void c_wave_ctrl::on_paint()
fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, m_back_color);
//show name
c_word::draw_string(m_surface, m_z_order, m_wave_name, m_wave_left + 10, rect.m_top, m_wave_name_font_type, m_wave_name_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
c_word::draw_string(m_surface, m_z_order, m_wave_name, m_wave_left + 10, rect.m_top, m_wave_name_font, m_wave_name_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
//show unit
c_word::draw_string(m_surface, m_z_order, m_wave_unit, m_wave_left + 60, rect.m_top, m_wave_unit_font_type, m_wave_unit_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
c_word::draw_string(m_surface, m_z_order, m_wave_unit, m_wave_left + 60, rect.m_top, m_wave_unit_font, m_wave_unit_color, GL_ARGB(0, 0, 0, 0), ALIGN_LEFT);
save_background();
}

View File

@ -72,10 +72,6 @@ void c_word::draw_string_in_rect(c_surface* surface, int z_order, const char *s,
{
return;
}
if (NULL == font)
{
ASSERT(FALSE);
}
int x, y;
get_string_pos(s, font, rect, align_type, x, y);
draw_string(surface, z_order, s, rect.m_left + x, rect.m_top + y, font, font_color, bg_color, ALIGN_LEFT);
@ -87,21 +83,11 @@ void c_word::draw_string(c_surface* surface, int z_order, const char *s, int x,
{
return;
}
if (NULL == font)
{
ASSERT(FALSE);
}
int offset = 0;
unsigned int utf8_code;
while (*s)
{
if (*s == '\n')
{
y += font->height;
offset = 0;
continue;
}
s += get_utf8_code(s, utf8_code);
offset += draw_single_char(surface, z_order, utf8_code, (x + offset), y, font, font_color, bg_color);
}
@ -160,26 +146,29 @@ const LATTICE* c_word::get_lattice(const FONT_INFO* font, unsigned int utf8_code
int c_word::draw_single_char(c_surface* surface, int z_order, unsigned int utf8_code, int x, int y, const FONT_INFO* font, unsigned int font_color, unsigned int bg_color)
{
if (NULL == font)
unsigned int error_color = 0xFFFFFFFF;
if (font)
{
ASSERT(FALSE);
return 0;
const LATTICE* p_lattice = get_lattice(font, utf8_code);
if (p_lattice)
{
draw_lattice(surface, z_order, x, y, p_lattice->width, font->height, p_lattice->p_data, font_color, bg_color);
return p_lattice->width;
}
}
else
{
error_color = GL_RGB(255, 0, 0);
}
const LATTICE* p_lattice = get_lattice(font, utf8_code);
if (p_lattice)
{
draw_lattice(surface, z_order, x, y, p_lattice->width, font->height, p_lattice->p_data, font_color, bg_color);
return p_lattice->width;
}
int len = font->height;
//lattice/font not found, draw mosaic
int len = 16;
for (int y_ = 0; y_ < len; y_++)
{
for (int x_ = 0; x_ < len; x_++)
{
((y_ % 4) == 0) ? surface->draw_pixel((x + x_), (y + y_), 0, z_order) :
surface->draw_pixel((x + x_), (y + y_), 0xFFFFFFFF, z_order);
surface->draw_pixel((x + x_), (y + y_), error_color, z_order);
}
}
return len;
@ -214,15 +203,12 @@ void c_word::draw_lattice(c_surface* surface, int z_order, int x, int y, int wid
}
}
int c_word::get_str_pixel_length(const char *s, const FONT_INFO* font)
int c_word::get_str_size(const char *s, const FONT_INFO* font, int& width, int& height)
{
if(NULL == s)
if(NULL == s || NULL == font)
{
return 0;
}
if (NULL == font)
{
ASSERT(FALSE);
width = height = 0;
return -1;
}
int lattice_width = 0;
@ -235,13 +221,15 @@ int c_word::get_str_pixel_length(const char *s, const FONT_INFO* font)
lattice_width += p_lattice?p_lattice->width:font->height;
s += utf8_bytes;
}
return lattice_width;
width = lattice_width;
height = font->height;
return 0;
}
void c_word::get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y)
{
int x_size = get_str_pixel_length(s, font);
int y_size = font->height;
int x_size, y_size;
get_str_size(s, font, x_size, y_size);
int height = rect.m_bottom - rect.m_top + 1;
int width = rect.m_right - rect.m_left + 1;