Move test main.c to tests/platform/
This commit is contained in:
parent
b0e83c4303
commit
90023459f5
|
|
@ -0,0 +1,78 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 by Federico Izzo IU2NUO, Niccolò Izzo IU2KIN and *
|
||||
* Silvano Seva IU2KWO *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <os.h>
|
||||
#include "gpio.h"
|
||||
#include "graphics.h"
|
||||
#include "hwconfig.h"
|
||||
#include "platform.h"
|
||||
|
||||
void platform_test()
|
||||
{
|
||||
gpio_togglePin(GREEN_LED);
|
||||
OS_ERR os_err;
|
||||
point_t pos_line1 = {0, 0};
|
||||
point_t pos_line2 = {0, 9};
|
||||
point_t pos_line3 = {0, 17};
|
||||
color_t color_white = {255, 255, 255};
|
||||
char *buf = "Platform Test";
|
||||
gfx_print(pos_line1, buf, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
||||
float vBat = platform_getVbat();
|
||||
float micLevel = platform_getMicLevel();
|
||||
float volumeLevel = platform_getVolumeLevel();
|
||||
uint8_t currentCh = platform_getChSelector();
|
||||
bool ptt = platform_getPttStatus();
|
||||
char buf2[26] = "";
|
||||
snprintf(buf2, sizeof(buf2), "bat:%.2f mic:%.2f", vBat, micLevel);
|
||||
char buf3[26] = "";
|
||||
snprintf(buf3, sizeof(buf3), "vol:%.2f ch:%d ptt:%s", volumeLevel, currentCh, ptt?"on":"off");
|
||||
gfx_print(pos_line2, buf2, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
||||
gfx_print(pos_line3, buf3, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
||||
gfx_render();
|
||||
while(gfx_renderingInProgress());
|
||||
OSTimeDlyHMSM(0u, 0u, 0u, 250u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
gpio_setMode(GREEN_LED, OUTPUT);
|
||||
|
||||
// Init the graphic stack
|
||||
gfx_init();
|
||||
platform_setBacklightLevel(255);
|
||||
|
||||
point_t origin = {0, SCREEN_HEIGHT / 2};
|
||||
color_t color_yellow = {250, 180, 19};
|
||||
char *buffer = "OpenRTX";
|
||||
|
||||
OS_ERR os_err;
|
||||
|
||||
// Task infinite loop
|
||||
while(1)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
gfx_print(origin, buffer, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow);
|
||||
//gfx_render();
|
||||
//while(gfx_renderingInProgress());
|
||||
platform_test();
|
||||
OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 by Federico Izzo IU2NUO, Niccolò Izzo IU2KIN and *
|
||||
* Silvano Seva IU2KWO *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <os.h>
|
||||
#include "gpio.h"
|
||||
#include "graphics.h"
|
||||
#include "hwconfig.h"
|
||||
#include "platform.h"
|
||||
|
||||
void printBits(uint16_t value, point_t pos)
|
||||
{
|
||||
char buf[16] = {0};
|
||||
|
||||
unsigned char i = 0;
|
||||
for(; i < 15; i++)
|
||||
{
|
||||
buf[i] = '0';
|
||||
if(value & (1 << i)) buf[i] += 1;
|
||||
}
|
||||
|
||||
color_t color_white = {255, 255, 255};
|
||||
gfx_print(pos, buf, FONT_SIZE_1, TEXT_ALIGN_LEFT, color_white);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
GPIOA->MODER = 0;
|
||||
GPIOB->MODER = 0;
|
||||
GPIOC->MODER = 0;
|
||||
GPIOD->MODER = 0;
|
||||
GPIOE->MODER = 0;
|
||||
|
||||
gpio_setMode(GREEN_LED, OUTPUT);
|
||||
gpio_setMode(LCD_BKLIGHT, OUTPUT);
|
||||
|
||||
// Init the graphic stack
|
||||
gfx_init();
|
||||
platform_setBacklightLevel(255);
|
||||
|
||||
OS_ERR os_err;
|
||||
|
||||
// Task infinite loop
|
||||
while(1)
|
||||
{
|
||||
gpio_togglePin(GREEN_LED);
|
||||
gfx_clearScreen();
|
||||
|
||||
point_t pos_line1 = {0, 0};
|
||||
point_t pos_line2 = {0, 17};
|
||||
point_t pos_line3 = {0, 35};
|
||||
point_t pos_line4 = {0, 53};
|
||||
point_t pos_line5 = {0, 71};
|
||||
|
||||
printBits((GPIOA->IDR & 0x0000FFFF), pos_line1);
|
||||
printBits((GPIOB->IDR & 0x0000FFFF), pos_line2);
|
||||
printBits((GPIOC->IDR & 0x0000FFFF), pos_line3);
|
||||
printBits((GPIOD->IDR & 0x0000FFFF), pos_line4);
|
||||
printBits((GPIOE->IDR & 0x0000FFFF), pos_line5);
|
||||
|
||||
gfx_render();
|
||||
while(gfx_renderingInProgress());
|
||||
OSTimeDlyHMSM(0u, 0u, 0u, 100u, OS_OPT_TIME_HMSM_STRICT, &os_err);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue