image/svg+xml
Brteve's API for EveApps
Version 0.0.1
The reference document for common folder of EveApps project.
 
Loading...
Searching...
No Matches
Common.h File Reference

Common functions. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "EVE_Hal.h"
#include "FT_Gpu.h"
#include "Gpu.h"
#include "Common.h"
#include "FileIo.h"
#include "FileTransfer.h"
#include "Gesture.h"
#include "Logo.h"
#include "Maths.h"
#include "Image.h"
#include "FlashHelper.h"

Go to the source code of this file.

Macros

#define __ALIGN_MASK(x, mask)   (((x)+(mask))&~(mask))
 Alignment.
 
#define ALIGN(x, a)   __ALIGN_MASK(x, a - 1)
 
#define FLASH_ADDRESS   (0x800000)
 Flash address.
 
#define ATFLASH(x)   (FLASH_ADDRESS | x / 32)
 
#define VP(x)   ((x) * VertextPrecision)
 
#define PRINTF_LEVEL   3
 
#define APP_PRINTF_INFO(M, ...)   printf("[INF] " M "\r\n", ##__VA_ARGS__)
 
#define APP_PRINTF_ERROR(M, ...)   printf("[ERROR] %s:%d: " M "\r\n", __func__, __LINE__, ##__VA_ARGS__)
 
#define APP_PRINTF_DEBUG(M, ...)   printf("[DBG] %s:%s:%d: " M "\r\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)
 
#define APP_INF   APP_PRINTF_INFO
 
#define APP_ERR   APP_PRINTF_ERROR
 
#define APP_DBG   APP_PRINTF_DEBUG
 
#define APP_DBG_H2(x)   APP_DBG(#x ": 0x%02x", (x))
 
#define APP_DBG_H8(x)   APP_DBG(#x ": 0x%08x", (x))
 
#define APP_DBG_D(x)   APP_DBG(#x ": %d" , (x))
 
#define APP_DBG_U(x)   APP_DBG(#x ": %u" , (x))
 
#define APP_DBG_F8(x)   APP_DBG(#x ": 0x%08f", (x))
 
#define APP_DBG_F2(x)   APP_DBG(#x ": 0x%02f", (x))
 
#define APP_DBG_S(x)   APP_DBG(#x ": %s" , (x))
 
#define INPUT_YES   1
 
#define INPUT_NO   0
 
#define Draw_Text_Format(phost, M, ...)
 
#define Draw_Text_Format2(phost, ms, M, ...)
 

Functions

void Gpu_Init (EVE_HalContext *phost)
 EVE initialzation.
 
void Gpu_Release (EVE_HalContext *phost)
 
uint32_t Get_SystemClock (EVE_HalContext *phost)
 Get system frequency in Hz.
 
uint32_t Draw_Point (EVE_HalContext *phost, uint32_t Rx, uint32_t Ry, uint32_t R)
 Helper function to draw a point.
 
void Calibration_Restore (EVE_HalContext *phost)
 
void Calibration_Save (EVE_HalContext *phost)
 
void Display_Start (EVE_HalContext *phost)
 
void Display_StartColor (EVE_HalContext *phost, uint8_t *bgColor, uint8_t *textColor)
 
void Display_End (EVE_HalContext *phost)
 
void Draw_TextColor (EVE_HalContext *phost, const char8_t *str, uint8_t *bgColor, uint8_t *textColor)
 
void Draw_Text (EVE_HalContext *phost, const char8_t *str)
 
void Draw_Text2 (EVE_HalContext *phost, const char8_t *str, int ms)
 
void Play_MuteSound (EVE_HalContext *phost)
 
void Get_VC1Dump (EVE_HalContext *phost, const char *filename)
 
void Play_Sound (EVE_HalContext *phost, uint8_t sound, uint8_t vol, uint8_t midi)
 
void Setup_Precision (uint32_t format)
 Setup vertex format and precision.
 
uint8_t Show_Diaglog_YesNo (EVE_HalContext *phost, const uint8_t *title, const uint8_t *msg)
 
void Show_Diaglog_Info (EVE_HalContext *phost, const uint8_t *msg)
 
uint8_t isSDcardDetected ()
 
void hintScreen (EVE_HalContext *phost, const uint8_t *msg)
 
void Flash_Init (EVE_HalContext *phost, const uint8_t *filePath, const uint8_t *fileName)
 
void WelcomeScreen (Gpu_Hal_Context_t *phost, char *info[])
 

Variables

uint32_t VertextFormat
 
uint32_t VertextPrecision
 
char textbuffer [1000]
 

Detailed Description

Common functions.

Author
Tuan Nguyen tuan..nosp@m.nguy.nosp@m.en@br.nosp@m.tchi.nosp@m.p.com
Date
2019

MIT License

Copyright (c) [2019] [Bridgetek Pte Ltd (BRTChip)]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file Common.h.

Macro Definition Documentation

◆ __ALIGN_MASK

#define __ALIGN_MASK (   x,
  mask 
)    (((x)+(mask))&~(mask))

Alignment.

Definition at line 60 of file Common.h.

◆ ALIGN

#define ALIGN (   x,
  a 
)    __ALIGN_MASK(x, a - 1)

Definition at line 61 of file Common.h.

◆ APP_DBG

#define APP_DBG   APP_PRINTF_DEBUG

Definition at line 93 of file Common.h.

◆ APP_DBG_D

#define APP_DBG_D (   x)    APP_DBG(#x ": %d" , (x))

Definition at line 102 of file Common.h.

◆ APP_DBG_F2

#define APP_DBG_F2 (   x)    APP_DBG(#x ": 0x%02f", (x))

Definition at line 105 of file Common.h.

◆ APP_DBG_F8

#define APP_DBG_F8 (   x)    APP_DBG(#x ": 0x%08f", (x))

Definition at line 104 of file Common.h.

◆ APP_DBG_H2

#define APP_DBG_H2 (   x)    APP_DBG(#x ": 0x%02x", (x))

Definition at line 100 of file Common.h.

◆ APP_DBG_H8

#define APP_DBG_H8 (   x)    APP_DBG(#x ": 0x%08x", (x))

Definition at line 101 of file Common.h.

◆ APP_DBG_S

#define APP_DBG_S (   x)    APP_DBG(#x ": %s" , (x))

Definition at line 106 of file Common.h.

◆ APP_DBG_U

#define APP_DBG_U (   x)    APP_DBG(#x ": %u" , (x))

Definition at line 103 of file Common.h.

◆ APP_ERR

#define APP_ERR   APP_PRINTF_ERROR

Definition at line 92 of file Common.h.

◆ APP_INF

#define APP_INF   APP_PRINTF_INFO

Definition at line 91 of file Common.h.

◆ APP_PRINTF_DEBUG

#define APP_PRINTF_DEBUG (   M,
  ... 
)    printf("[DBG] %s:%s:%d: " M "\r\n", __FILE__, __func__, __LINE__, ##__VA_ARGS__)

Definition at line 81 of file Common.h.

◆ APP_PRINTF_ERROR

#define APP_PRINTF_ERROR (   M,
  ... 
)    printf("[ERROR] %s:%d: " M "\r\n", __func__, __LINE__, ##__VA_ARGS__)

Definition at line 80 of file Common.h.

◆ APP_PRINTF_INFO

#define APP_PRINTF_INFO (   M,
  ... 
)    printf("[INF] " M "\r\n", ##__VA_ARGS__)

Definition at line 79 of file Common.h.

◆ ATFLASH

#define ATFLASH (   x)    (FLASH_ADDRESS | x / 32)

Definition at line 65 of file Common.h.

◆ Draw_Text_Format

#define Draw_Text_Format (   phost,
  M,
  ... 
)
Value:
{ \
sprintf(textbuffer, M, ##__VA_ARGS__); \
Draw_Text(phost, textbuffer); \
}
char textbuffer[1000]
Definition Common.c:35

Definition at line 111 of file Common.h.

112{ \
113 sprintf(textbuffer, M, ##__VA_ARGS__); \
114 Draw_Text(phost, textbuffer); \
115}

◆ Draw_Text_Format2

#define Draw_Text_Format2 (   phost,
  ms,
  M,
  ... 
)
Value:
{ \
sprintf(textbuffer, M, ##__VA_ARGS__); \
Draw_Text2(phost, textbuffer, ms);\
}

Definition at line 117 of file Common.h.

118{ \
119 sprintf(textbuffer, M, ##__VA_ARGS__); \
120 Draw_Text2(phost, textbuffer, ms);\
121}

◆ FLASH_ADDRESS

#define FLASH_ADDRESS   (0x800000)

Flash address.

Definition at line 64 of file Common.h.

◆ INPUT_NO

#define INPUT_NO   0

Definition at line 108 of file Common.h.

◆ INPUT_YES

#define INPUT_YES   1

Definition at line 107 of file Common.h.

◆ PRINTF_LEVEL

#define PRINTF_LEVEL   3

macro: PRINTF_LEVEL range: 0-3 0: Disable printf 1: Only APP_INF messages and printf function calls 2: Only APP_ERR messages 3: APP_ERR messages and APP_DBG messages

Definition at line 78 of file Common.h.

◆ VP

#define VP (   x)    ((x) * VertextPrecision)

Definition at line 66 of file Common.h.

Function Documentation

◆ Calibration_Restore()

void Calibration_Restore ( EVE_HalContext phost)

Definition at line 383 of file Common.c.

383 {
390}
static uint32_t a
Definition Common.c:36
static uint32_t b
Definition Common.c:37
static uint32_t d
Definition Common.c:39
static uint32_t e
Definition Common.c:40
static uint32_t c
Definition Common.c:38
static uint32_t f
Definition Common.c:41
#define REG_TOUCH_TRANSFORM_D
#define REG_TOUCH_TRANSFORM_F
#define REG_TOUCH_TRANSFORM_B
#define REG_TOUCH_TRANSFORM_C
#define REG_TOUCH_TRANSFORM_E
#define REG_TOUCH_TRANSFORM_A
EVE_HAL_EXPORT void EVE_Hal_wr32(EVE_HalContext *phost, uint32_t addr, uint32_t v)
Write 4 bytes to Coprocessor's memory.
Definition EVE_Hal.c:248

◆ Calibration_Save()

void Calibration_Save ( EVE_HalContext phost)

Definition at line 392 of file Common.c.

392 {
399}
EVE_HAL_EXPORT uint32_t EVE_Hal_rd32(EVE_HalContext *phost, uint32_t addr)
Read 4 bytes from Coprocessor's memory.
Definition EVE_Hal.c:189

◆ Display_End()

void Display_End ( EVE_HalContext phost)

Definition at line 413 of file Common.c.

413 {
414 EVE_Cmd_wr32(phost, DISPLAY());
415 EVE_CoCmd_swap(phost);
416 EVE_Cmd_waitFlush(phost);
417}
EVE_HAL_EXPORT bool EVE_Cmd_wr32(EVE_HalContext *phost, uint32_t value)
Write 4 bytes to Coprocessor's command fifo.
Definition EVE_Cmd.c:394
static void EVE_CoCmd_swap(EVE_HalContext *phost)
Send CMD_SWAP.
Definition EVE_CoCmd.h:170
#define DISPLAY()
void EVE_Cmd_waitFlush(EVE_HalContext *host)
Definition Gpu_Hal.cpp:775

◆ Display_Start()

void Display_Start ( EVE_HalContext phost)

Definition at line 409 of file Common.c.

409 {
410 Display_StartColor(phost, (uint8_t[]) { 255, 255, 255 }, (uint8_t[]) { 255, 255, 255 });
411}
void Display_StartColor(EVE_HalContext *phost, uint8_t *bgColor, uint8_t *textColor)
Definition Common.c:401
unsigned char uint8_t

◆ Display_StartColor()

void Display_StartColor ( EVE_HalContext phost,
uint8_t bgColor,
uint8_t textColor 
)

Definition at line 401 of file Common.c.

401 {
402 EVE_CoCmd_dlStart(phost);
403 EVE_Cmd_wr32(phost, CLEAR_COLOR_RGB(bgColor[0], bgColor[1], bgColor[2]));
404 EVE_Cmd_wr32(phost, CLEAR(1, 1, 1));
405 EVE_Cmd_wr32(phost, COLOR_RGB(textColor[0], textColor[1], textColor[2]));
407}
uint32_t VertextFormat
Definition Common.c:43
static void EVE_CoCmd_dlStart(EVE_HalContext *phost)
Send CMD_DLSTART.
Definition EVE_CoCmd.h:159
#define CLEAR(c, s, t)
#define VERTEX_FORMAT(frac)
#define COLOR_RGB(red, green, blue)
#define CLEAR_COLOR_RGB(red, green, blue)

◆ Draw_Point()

uint32_t Draw_Point ( EVE_HalContext phost,
uint32_t  Rx,
uint32_t  Ry,
uint32_t  R 
)

Helper function to draw a point.

Parameters
phost
Rx
Ry
R
Returns
uint32_t

Definition at line 346 of file Common.c.

346 {
347 EVE_Cmd_wr32(phost, POINT_SIZE(VP(R)));
348 EVE_Cmd_wr32(phost, BEGIN(POINTS));
349 EVE_Cmd_wr32(phost, VERTEX2F(VP(Rx), VP(Ry)));
350 return 1;
351}
#define VP(x)
Definition Common.h:66
#define VERTEX2F(x, y)
#define POINT_SIZE(size)
#define BEGIN(prim)
#define POINTS

◆ Draw_Text()

void Draw_Text ( EVE_HalContext phost,
const char8_t str 
)

Definition at line 442 of file Common.c.

442 {
443 Gpu_Text(phost, str, (uint8_t[]) { 0xff, 0xff, 0xff }, (uint8_t[]) { 0, 0, 0});
444 EVE_sleep(2000);
445}
static void Gpu_Text(EVE_HalContext *phost, const char8_t *str, uint8_t *bgColor, uint8_t *textColor)
Definition Common.c:419
EVE_HAL_EXPORT void EVE_sleep(uint32_t ms)
Sleep in milisecond.

◆ Draw_Text2()

void Draw_Text2 ( EVE_HalContext phost,
const char8_t str,
int  ms 
)

Definition at line 447 of file Common.c.

447 {
448 Gpu_Text(phost, str, (uint8_t[]) { 0xff, 0xff, 0xff }, (uint8_t[]) { 0, 0, 0 });
449 EVE_sleep(ms);
450}

◆ Draw_TextColor()

void Draw_TextColor ( EVE_HalContext phost,
const char8_t str,
uint8_t bgColor,
uint8_t textColor 
)

Definition at line 437 of file Common.c.

437 {
438 Gpu_Text(phost, str, bgColor, textColor);
439 EVE_sleep(2000);
440}

◆ Flash_Init()

void Flash_Init ( EVE_HalContext phost,
const uint8_t filePath,
const uint8_t fileName 
)

Definition at line 524 of file Common.c.

525 {
526#if defined(_WIN32)
527#define _WHERE "PC"
528#elif defined(EMBEDDED_PLATFORM)
529#define _WHERE "SDcard"
530#endif
531
532 EVE_Util_loadSdCard(phost);
533#if !defined(BT8XXEMU_PLATFORM) && defined(EVE_FLASH_AVAILABLE)
535 if (!isSDcardDetected()) {
536 hintScreen(phost,
537 "Program the correct flash image to ensure EvChargePoint boots up successfully");
538 return;
539 } else {
541 if (!Show_Diaglog_YesNo(phost, "Flash programming",
542 "Program the flash with the file in " _WHERE "?")) {
544 return;
545 }
546
548 int sent = Ftf_Write_File_To_Flash_With_Progressbar(phost, filePath,
549 fileName, 0);
550
552 if (0 >= sent) {
553 uint8_t count = 5;
554 uint8_t msg[1000];
555 while (count) {
556#if defined(FT9XX_PLATFORM) || defined(EVE_PLATFORM_RP2040)
557 snprintf(msg, 1000, "Error: Cannot open file: %s, reset in %us",
558 filePath, count);
559#else
560 snprintf(msg, 1000, "Error: Cannot open file: %s, exit in %u s",
561 fileName, count);
562#endif
563 Show_Diaglog_Info(phost, msg);
564 EVE_sleep(1000);
565 count--;
566 }
567 exit(0);
568 }
569 }
570#endif
571}
void hintScreen(EVE_HalContext *phost, const uint8_t *msg)
Definition Common.c:520
void Show_Diaglog_Info(EVE_HalContext *phost, const uint8_t *msg)
Definition Common.c:573
uint8_t Show_Diaglog_YesNo(EVE_HalContext *phost, const uint8_t *title, const uint8_t *msg)
Definition Common.c:658
uint8_t isSDcardDetected()
Definition Common.c:510
EVE_HAL_EXPORT bool EVE_Util_loadSdCard(EVE_HalContext *phost)
Mount the SDcard.

◆ Get_SystemClock()

uint32_t Get_SystemClock ( EVE_HalContext phost)

Get system frequency in Hz.

Parameters
phostEVE_HalContext* pointer
Returns
uint32_t System clock requency in Hz

Definition at line 320 of file Common.c.

320 {
321 EVE_Hal_rd32(phost, REG_CLOCK); // warm up
322
323 uint32_t c0 = EVE_Hal_rd32(phost, REG_CLOCK);
324 uint32_t c1 = EVE_Hal_rd32(phost, REG_CLOCK);
325
326 uint32_t overhead = c1 - c0;
327
328 c0 = EVE_Hal_rd32(phost, REG_CLOCK);
329 EVE_sleep(1000);
330 c1 = EVE_Hal_rd32(phost, REG_CLOCK);
331
332 uint32_t freq = (uint32_t) round((c1 - c0) - overhead);
333
334 return freq;
335}
#define REG_CLOCK
unsigned int uint32_t

◆ Get_VC1Dump()

void Get_VC1Dump ( EVE_HalContext phost,
const char *  filename 
)

Definition at line 457 of file Common.c.

457 {
458#if defined(MSVC_PLATFORM) || defined(BT8XXEMU_PLATFORM)
459#pragma warning(push)
460#pragma warning(disable : 4996)
461 FILE* vc1dump = fopen(filename, "wb");
462#pragma warning(pop)
463
464 if (!vc1dump) {
465 APP_ERR("Cannot open file %s", filename);
466 return;
467 }
468
469 const uint32_t version = 110;
470 const uint32_t w = DispWidth;
471 const uint32_t h = DispHeight;
472 const uint32_t macro0 = 0;
473 const uint32_t macro1 = 0;
474 const uint32_t CRC_IMAGE = 0;
475
476 fwrite(&version, 4, 1, vc1dump);
477 fwrite(&w, 4, 1, vc1dump);
478 fwrite(&h, 4, 1, vc1dump);
479 fwrite(&macro0, 4, 1, vc1dump);
480 fwrite(&macro1, 4, 1, vc1dump);
481 fwrite(&CRC_IMAGE, 4, 1, vc1dump);
482
483 uint8_t* buffer = malloc(RAM_G_SIZE);
484 if (!buffer) {
485 APP_ERR("Malloc failed");
486 fclose(vc1dump);
487 return;
488 }
489
490 memset(buffer, 0, RAM_G_SIZE);
492 fwrite(buffer, 1, RAM_G_SIZE, vc1dump);
493
494 memset(buffer, 0, RAM_G_SIZE);
496 fwrite(buffer, 1, EVE_DL_SIZE, vc1dump);
497
498 fclose(vc1dump);
499 free(buffer);
500#endif
501}
#define APP_ERR
Definition Common.h:92
#define RAM_DL
Definition EVE_GpuDefs.h:95
#define RAM_G_SIZE
Definition EVE_GpuDefs.h:98
#define RAM_G
Definition EVE_GpuDefs.h:77
#define EVE_DL_SIZE
Definition EVE_GpuDefs.h:56
EVE_HAL_EXPORT void EVE_Hal_rdMem(EVE_HalContext *phost, uint8_t *result, uint32_t addr, uint32_t size)
Read a block data from Coprocessor's memory.
Definition EVE_Hal.c:206
static ft_uint32_t ft_uint8_t * buffer
Definition FT_Gpu_Hal.h:139
#define DispHeight
Definition Gpu_Hal.h:106
#define DispWidth
Definition Gpu_Hal.h:105

◆ Gpu_Init()

void Gpu_Init ( EVE_HalContext phost)

EVE initialzation.

Parameters
phost

Definition at line 240 of file Common.c.

240 {
241 EVE_CHIPID_T chipId;
242 size_t deviceIdx;
243
244 EVE_HalParameters params;
245
246#if defined(BT8XXEMU_PLATFORM)
247 printf(BT8XXEMU_version());
248 BT8XXEMU_EmulatorParameters emulatorParams;
249#if defined(EVE_FLASH_AVAILABLE)
250 BT8XXEMU_FlashParameters flashParams;
251#endif
252#endif
253
255
256#ifdef EVE_MULTI_TARGET
257 EVE_Util_selectDeviceInteractive(&chipId, &deviceIdx);
258#else
259 chipId = EVE_SUPPORT_CHIPID;
260 deviceIdx = -1;
261#endif
262
263 EVE_Hal_defaultsEx(&params, deviceIdx);
264 params.CbCmdWait = cbCmdWait;
265
266#ifdef BT8XXEMU_PLATFORM
267 EVE_Util_emulatorDefaults(&params, &emulatorParams, chipId);
268#if defined(EVE_FLASH_AVAILABLE)
269 EVE_Util_emulatorFlashDefaults(&params, &emulatorParams, &flashParams, L"__Flash.bin");
270#endif
271#endif
272
273 EVE_Hal_open(phost, &params);
274
275#ifdef EVE_MULTI_TARGET
277#else
279#endif
280
281#ifdef DISPLAY_RESOLUTION_WXGA
283 EVE_Hal_wr8(phost, REG_CPURESET, 2);
284 EVE_Hal_wr16(phost, REG_TOUCH_CONFIG, 0x05D0); //for Goodix touch panel
285 EVE_Hal_wr8(phost, REG_CPURESET, 0);
286 EVE_sleep(300);
287#endif
288
289#if defined(BT817_ENABLE) || defined(BT818_ENABLE)
292
294 EVE_CoCmd_apiLevel(phost, 2);
295 EVE_Cmd_waitFlush(phost);
296 printf("Set APILEVEL to BT817/8 (2)\n");
297#else
298 printf("Set APILEVEL to default (1)\n");
299#endif
300
301#if defined(FT900_PLATFORM) || defined(FT93X_PLATFORM) || defined(RP2040_PLATFORM)
302 EVE_Util_loadSdCard(phost);
303#endif
304
305 // Precision control
306 Setup_Precision(4); // Default vertext format = 4
307}
bool cbCmdWait(struct EVE_HalContext *phost)
Callback function.
Definition Common.c:82
void Setup_Precision(uint32_t format)
Setup vertex format and precision.
Definition Common.c:51
void Init_CapacitiveTouch(EVE_HalContext *phost)
Capacitive Touch initialzation.
Definition Common.c:92
#define EVE_CoCmd_apiLevel(phost, level)
Definition EVE_CoCmd.h:352
#define EVE_SUPPORT_CHIPID
#define REG_TOUCH_CONFIG
#define REG_ADAPTIVE_FRAMERATE
#define REG_CPURESET
EVE_HAL_EXPORT void EVE_Hal_defaultsEx(EVE_HalParameters *parameters, size_t deviceIdx)
Setup default parameters for Eve_Hal framework.
Definition EVE_Hal.c:89
EVE_HAL_EXPORT bool EVE_Hal_open(EVE_HalContext *phost, const EVE_HalParameters *parameters)
Open the Eve_Hal framework.
Definition EVE_Hal.c:103
EVE_HAL_EXPORT void EVE_Hal_wr8(EVE_HalContext *phost, uint32_t addr, uint8_t v)
Write 8 bits to Coprocessor's memory.
Definition EVE_Hal.c:220
EVE_HAL_EXPORT void EVE_Hal_wr16(EVE_HalContext *phost, uint32_t addr, uint16_t v)
Write 2 bytes to Coprocessor's memory.
Definition EVE_Hal.c:234
EVE_HAL_EXPORT EVE_HalPlatform * EVE_Hal_initialize()
Eve_Hal framework initialization.
Definition EVE_Hal.c:52
EVE_CHIPID_T
Definition EVE_HalDefs.h:72
EVE_HAL_EXPORT bool EVE_Util_bootupConfigInteractive(EVE_HalContext *phost, EVE_DISPLAY_T display)
Calls EVE_Util_bootup and EVE_Util_config using the default parameters. Falls back to no interactivit...
Definition EVE_Util.c:2582
EVE_HAL_EXPORT bool EVE_Util_bootupConfig(EVE_HalContext *phost)
Bootup Coprocessor.
Definition EVE_Util.c:1898
static void EVE_Util_selectDeviceInteractive(EVE_CHIPID_T *chipId, size_t *deviceIdx)
Definition EVE_Util.h:178
@ EVE_DISPLAY_DEFAULT
Definition EVE_Util.h:102
BT8XXEMU_API const char * BT8XXEMU_version()
EVE_Callback CbCmdWait

◆ Gpu_Release()

void Gpu_Release ( EVE_HalContext phost)

Definition at line 309 of file Common.c.

309 {
310 EVE_Hal_close(phost);
312}
EVE_HAL_EXPORT void EVE_Hal_close(EVE_HalContext *phost)
Close the Eve_Hal framework.
Definition EVE_Hal.c:116
EVE_HAL_EXPORT void EVE_Hal_release()
Close Eve_Hal framework.
Definition EVE_Hal.c:64

◆ hintScreen()

void hintScreen ( EVE_HalContext phost,
const uint8_t msg 
)

Definition at line 520 of file Common.c.

520 {
521 Draw_Text(phost, msg);
522}
void Draw_Text(EVE_HalContext *phost, const char8_t *str)
Definition Common.c:442

◆ isSDcardDetected()

uint8_t isSDcardDetected ( )

Definition at line 510 of file Common.c.

510 {
511#if defined(MSVC_PLATFORM) || defined(BT8XXEMU_PLATFORM)
512 return true;
513#elif defined(FT9XX_PLATFORM)
514 return sdhost_card_detect() == SDHOST_CARD_INSERTED;
515#else
516 return true;
517#endif
518}

◆ Play_MuteSound()

void Play_MuteSound ( EVE_HalContext phost)

Definition at line 452 of file Common.c.

452 {
453 EVE_Hal_wr16(phost, REG_SOUND, 0x0060);
454 EVE_Hal_wr8(phost, REG_PLAY, 0x01);
455}
#define REG_SOUND
#define REG_PLAY

◆ Play_Sound()

void Play_Sound ( EVE_HalContext phost,
uint8_t  sound,
uint8_t  vol,
uint8_t  midi 
)

Definition at line 503 of file Common.c.

503 {
504 uint16_t val = (uint16_t) ((midi << 8) | sound);
505 EVE_Hal_wr8(phost, REG_VOL_SOUND, vol);
506 EVE_Hal_wr16(phost, REG_SOUND, val);
507 EVE_Hal_wr8(phost, REG_PLAY, 1);
508}
#define REG_VOL_SOUND
unsigned short uint16_t

◆ Setup_Precision()

void Setup_Precision ( uint32_t  format)

Setup vertex format and precision.

Parameters
formatVertext format

Definition at line 51 of file Common.c.

51 {
52 VertextFormat = format;
53
54 switch (VertextFormat) {
55 case 0:
57 break;
58 case 1:
60 break;
61 case 2:
63 break;
64 case 3:
66 break;
67 case 4:
69 break;
70 default:
72 break;
73 }
74}
uint32_t VertextPrecision
Definition Common.c:44

◆ Show_Diaglog_Info()

void Show_Diaglog_Info ( EVE_HalContext phost,
const uint8_t msg 
)

fade the whole LCD

diag border

center part

top part

bottom part

Definition at line 573 of file Common.c.

573 {
574 uint8_t ret = INPUT_NO;
575 const uint32_t tag_y = 1;
576 const uint32_t tag_n = 2;
577
578 const uint16_t border = 2; // pixel
579 const uint16_t base_w = 800;
580 const uint16_t base_h = 600;
581 uint16_t w = 400;
582 uint16_t h = 200;
583 uint16_t x = (base_w - w) / 2;
584 uint16_t y = (base_h - h) / 2;
585 uint8_t htop = 50;
586 uint8_t hbottom = 50;
587 uint8_t font = 20;
588
589 uint16_t btn_h = 40;
590 uint16_t btn_w = 100;
591
592 uint32_t ratio = base_w * 100 / DispWidth;
593
594 if (ratio != 100) {
595 w = w * 100 / ratio;
596 h = h * 100 / ratio;
597 btn_w = btn_w * 100 / ratio;
598 btn_h = btn_h * 100 / ratio;
599 x = (DispWidth - w) / 2;
600 y = (DispHeight - h) / 2;
601 htop = htop * 100 / ratio;
602 hbottom = hbottom * 100 / ratio;
603
604 ratio += (100 - ratio) / 2;
605 font = font * 100 / ratio;
606 if (font > 31)
607 font = 31;
608 if (font < 16)
609 font = 16;
610 if (font == 17 || font == 19)
611 font = 18;
612 }
613
614 Display_Start(phost);
615
617 EVE_Cmd_wr32(phost, COLOR_RGB(0x3F, 0x3F, 0x3F));
618 EVE_Cmd_wr32(phost, BEGIN(RECTS));
619 EVE_Cmd_wr32(phost, VERTEX2F(0, 0));
621
623 EVE_Cmd_wr32(phost, COLOR_RGB(0xE1, 0xE1, 0xE1));
624 EVE_Cmd_wr32(phost, BEGIN(RECTS));
625 EVE_Cmd_wr32(phost, VERTEX2F(VP(x), VP(y)));
626 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w), VP(y + h)));
627
629 EVE_Cmd_wr32(phost, COLOR_RGB(0xFF, 0xFF, 0xFF));
630 EVE_Cmd_wr32(phost, BEGIN(RECTS));
631 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + border), VP(y + border)));
632 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + h - border)));
633
635 EVE_Cmd_wr32(phost, COLOR_RGB(0xF3, 0xF3, 0xF3));
636 EVE_Cmd_wr32(phost, BEGIN(RECTS));
637 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + border), VP(y + border)));
638 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + htop)));
639
641 EVE_Cmd_wr32(phost, COLOR_RGB(0xF3, 0xF3, 0xF3));
642 EVE_Cmd_wr32(phost, BEGIN(RECTS));
643 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + border), VP(y + h - hbottom + border)));
644 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + h - border)));
645
646 font = font * 8 / 10;
647 if (font < 16)
648 font = 16;
649 if (font == 17 || font == 19)
650 font = 18;
651 EVE_Cmd_wr32(phost, COLOR_RGB(0x78, 0x78, 0x78));
652 EVE_CoCmd_text(phost, x + border + 30, y + h / 2 - 20, font, 0, msg);
653
654 Display_End(phost);
655
656}
void Display_Start(EVE_HalContext *phost)
Definition Common.c:409
void Display_End(EVE_HalContext *phost)
Definition Common.c:413
#define INPUT_NO
Definition Common.h:108
EVE_HAL_EXPORT void EVE_CoCmd_text(EVE_HalContext *phost, int16_t x, int16_t y, int16_t font, uint16_t options, const char *s,...)
Send CMD_TEXT.
#define RECTS

◆ Show_Diaglog_YesNo()

uint8_t Show_Diaglog_YesNo ( EVE_HalContext phost,
const uint8_t title,
const uint8_t msg 
)

fade the whole LCD

diag border

center part

top part

bottom part

diag message

diag button yes/no

Definition at line 658 of file Common.c.

659 {
660 uint8_t ret = INPUT_NO;
661 const uint32_t tag_y = 1;
662 const uint32_t tag_n = 2;
663
664 const uint16_t border = 2; // pixel
665 const uint16_t base_w = 800;
666 const uint16_t base_h = 600;
667 uint16_t w = 400;
668 uint16_t h = 200;
669 uint16_t x = (base_w - w) / 2;
670 uint16_t y = (base_h - h) / 2;
671 uint8_t htop = 50;
672 uint8_t hbottom = 50;
673 uint8_t font = 20;
674
675 uint16_t btn_h = 30;
676 uint16_t btn_w = 80;
677
678 uint32_t ratio = base_w * 100 / DispWidth;
679
680 if (ratio != 100) {
681 w = w * 100 / ratio;
682 h = h * 100 / ratio;
683 btn_w = btn_w * 100 / ratio;
684 btn_h = btn_h * 100 / ratio;
685 x = (DispWidth - w) / 2;
686 y = (DispHeight - h) / 2;
687 htop = htop * 100 / ratio;
688 hbottom = hbottom * 100 / ratio;
689
690 ratio += (100 - ratio) / 2;
691 font = font * 100 / ratio;
692 if (font > 31)
693 font = 31;
694 if (font < 16)
695 font = 16;
696 if (font == 17 || font == 19)
697 font = 18;
698 }
699
700 do {
701 Display_Start(phost);
702
704 EVE_Cmd_wr32(phost, COLOR_RGB(0x3F, 0x3F, 0x3F));
705 EVE_Cmd_wr32(phost, BEGIN(RECTS));
706 EVE_Cmd_wr32(phost, VERTEX2F(0, 0));
708
710 EVE_Cmd_wr32(phost, COLOR_RGB(0xE1, 0xE1, 0xE1));
711 EVE_Cmd_wr32(phost, BEGIN(RECTS));
712 EVE_Cmd_wr32(phost, VERTEX2F(VP(x), VP(y)));
713 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w), VP(y + h)));
714
716 EVE_Cmd_wr32(phost, COLOR_RGB(0xFF, 0xFF, 0xFF));
717 EVE_Cmd_wr32(phost, BEGIN(RECTS));
718 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + border), VP(y + border)));
719 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + h - border)));
720
722 EVE_Cmd_wr32(phost, COLOR_RGB(0x46, 0x50, 0x52));
723 EVE_Cmd_wr32(phost, BEGIN(RECTS));
724 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + border), VP(y + border)));
725 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + htop)));
726
728 EVE_Cmd_wr32(phost, COLOR_RGB(0xF3, 0xF3, 0xF3));
729 EVE_Cmd_wr32(phost, BEGIN(RECTS));
730 EVE_Cmd_wr32(phost,
731 VERTEX2F(VP(x + border), VP(y + h - hbottom + border)));
732 EVE_Cmd_wr32(phost, VERTEX2F(VP(x + w - border), VP(y + h - border)));
733
735 EVE_Cmd_wr32(phost, COLOR_RGB(0xFF, 0xFF, 0xFF));
736 EVE_CoCmd_text(phost, x + border + 10, y + border + 10, font, 0, title);
737
738 uint32_t font2 = font * 8 / 10;
739 if (font2 < 16)
740 font2 = 16;
741 if (font2 == 17 || font2 == 19)
742 font2 = 18;
743 EVE_Cmd_wr32(phost, COLOR_RGB(0x78, 0x78, 0x78));
744 EVE_CoCmd_fillWidth(phost, w);
745 EVE_CoCmd_text(phost, x + border + 30, y + h / 2 - 20, font2, OPT_FILL, msg);
746
748 EVE_Cmd_wr32(phost, COLOR_RGB(0xFF, 0xFF, 0xFF));
749 const uint16_t btn_margin = 25;
750 EVE_Cmd_wr32(phost, TAG(tag_y));
751 EVE_CoCmd_button(phost, x + w / 2 - btn_w - btn_margin,
752 y + h - hbottom + border + (hbottom - btn_h) / 2, btn_w, btn_h,
753 font, 0, "Yes");
754
755 EVE_Cmd_wr32(phost, TAG(tag_n));
756 EVE_CoCmd_button(phost, x + w / 2 + btn_margin,
757 y + h - hbottom + border + (hbottom - btn_h) / 2, btn_w, btn_h,
758 font, 0, "No");
759
760 Display_End(phost);
761
762 Gesture_Renew(phost);
763 if (Gesture_Get()->tagReleased == tag_y) {
764 return true;
765 } else if (Gesture_Get()->tagReleased == tag_n) {
766 return false;
767 }
768 } while (true);
769
770 return false;
771}
EVE_HAL_EXPORT void EVE_CoCmd_button(EVE_HalContext *phost, int16_t x, int16_t y, int16_t w, int16_t h, int16_t font, uint16_t options, const char *s,...)
Send CMD_BUTTON.
static void EVE_CoCmd_fillWidth(EVE_HalContext *phost, uint32_t s)
Send CMD_FILLWIDTH.
Definition EVE_CoCmd.h:1238
#define OPT_FILL
#define TAG(s)
Gesture_Touch_t * Gesture_Get()
Get gesture data.
Definition Gesture.c:198
Gesture_Touch_t * Gesture_Renew(Gpu_Hal_Context_t *phost)
Refresh gesture data.
Definition Gesture.c:173

◆ WelcomeScreen()

void WelcomeScreen ( Gpu_Hal_Context_t phost,
char *  info[] 
)

Definition at line 782 of file Common.c.

783{
785 Gpu_Hal_WrCmd32(phost, 0);
786#if defined(MSVC_PLATFORM) || defined(MSVC_FT800EMU)
787 EVE_Cmd_wrMem(phost,home_start_icon,sizeof(home_start_icon)); //Load from RAM
788#else
789 EVE_Cmd_wrProgMem(phost,home_start_icon,sizeof(home_start_icon)); //Load from Flash
790#endif
791 EVE_Cmd_waitFlush(phost);
792
793 Display_Start(phost);
794 EVE_Cmd_wr32(phost, BITMAP_HANDLE(0)); // handle for background stars
795 EVE_Cmd_wr32(phost, BITMAP_SOURCE(0)); // Starting address in gram
796 EVE_Cmd_wr32(phost, BITMAP_LAYOUT(L4, 16, 32)); // format
797 EVE_Cmd_wr32(phost, BITMAP_SIZE(NEAREST, BORDER, BORDER, 32, 32 ));
798 Display_End(phost);
799
800 do
801 {
802 Display_StartColor(phost, (uint8_t[]) { 255, 255, 255 }, (uint8_t[]) { 219, 180, 150 });
803 EVE_Cmd_wr32(phost, SAVE_CONTEXT());
804 EVE_Cmd_wr32(phost, COLOR_A(220));
806 EVE_Cmd_wr32(phost, VERTEX2F(0, VP(DispHeight)));
808 EVE_Cmd_wr32(phost, COLOR_A(255));
809 EVE_Cmd_wr32(phost, RESTORE_CONTEXT());
810 EVE_Cmd_wr32(phost, COLOR_RGB(0, 0, 0));
811
812 // information
813 EVE_CoCmd_text(phost, DispWidth/2, 20, 28, OPT_CENTER , info[0]);
814 EVE_CoCmd_text(phost, DispWidth/2, 60, 26, OPT_CENTERX , info[1]);
815 EVE_CoCmd_text(phost, DispWidth/2, 80, 26, OPT_CENTERX , info[2]);
816 EVE_CoCmd_text(phost, DispWidth/2, 100, 26, OPT_CENTERX, info[3]);
817 EVE_CoCmd_text(phost, DispWidth/2, DispHeight/2 - 32, 26, OPT_CENTER, "Click to play");
818
819 // play button circle boundary
820 EVE_Cmd_wr32(phost, COLOR_RGB(100, 100, 100));
821 EVE_Cmd_wr32(phost, BEGIN(FTPOINTS));
822 EVE_Cmd_wr32(phost, POINT_SIZE(20*16));
823 EVE_Cmd_wr32(phost, TAG('P'));
825 EVE_Cmd_wr32(phost, COLOR_RGB(180, 35, 35));
826
827 // play button
828 EVE_Cmd_wr32(phost, BEGIN(BITMAPS));
829 EVE_Cmd_wr32(phost, CELL(4));
830 EVE_Cmd_wr32(phost, VERTEX2F(VP(DispWidth/2 -14), VP(DispHeight/2 - 15)));
831 EVE_Cmd_wr32(phost, END());
832 Display_End(phost);
833
834 }while(Gpu_Hal_Rd8(phost, REG_TOUCH_TAG)!='P');
835 Play_Sound(phost, 0x50, 255, 0xc0);
836}
PROGMEM prog_uchar8_t home_start_icon[]
Definition Common.c:780
void Play_Sound(EVE_HalContext *phost, uint8_t sound, uint8_t vol, uint8_t midi)
Definition Common.c:503
EVE_HAL_EXPORT bool EVE_Cmd_wrMem(EVE_HalContext *phost, const uint8_t *buffer, uint32_t size)
Write buffer to Coprocessor's comand fifo.
Definition EVE_Cmd.c:291
EVE_HAL_EXPORT bool EVE_Cmd_wrProgMem(EVE_HalContext *phost, eve_progmem_const uint8_t *buffer, uint32_t size)
Write buffer in ProgMem to Coprocessor's comand fifo.
Definition EVE_Cmd.c:307
#define REG_TOUCH_TAG
#define SAVE_CONTEXT()
#define NEAREST
#define BITMAP_LAYOUT(format, linestride, height)
#define BITMAPS
#define BITMAP_HANDLE(handle)
#define L4
#define FTPOINTS
#define RESTORE_CONTEXT()
#define END()
#define CMD_INFLATE
#define BITMAP_SOURCE(addr)
#define OPT_CENTERX
#define BORDER
#define OPT_CENTER
#define EDGE_STRIP_A
#define BITMAP_SIZE(filter, wrapx, wrapy, width, height)
#define COLOR_A(alpha)
#define CELL(cell)
#define Gpu_Hal_WrCmd32
Definition Gpu_Hal.h:225
#define Gpu_Hal_Rd8
Definition Gpu_Hal.h:204

Variable Documentation

◆ textbuffer

char textbuffer[1000]
extern

Definition at line 35 of file Common.c.

◆ VertextFormat

uint32_t VertextFormat
extern

Definition at line 43 of file Common.c.

◆ VertextPrecision

uint32_t VertextPrecision
extern

Definition at line 44 of file Common.c.