Author Topic: Open Source Laser Tag project - ARMada  (Read 31302 times)

Theuer

  • Full Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Open Source Laser Tag project - ARMada
« Reply #285 on: August 09, 2017, 06:43:13 PM »
  What programmer do you use? Which do you indicate to buy?
  Here in Brazil I found ST-Link V2, is it works?
 Thanks again.

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #286 on: August 11, 2017, 05:03:11 AM »
  What programmer do you use? Which do you indicate to buy?
  Here in Brazil I found ST-Link V2, is it works?
 Thanks again.

I use ST-Link which is installed on the developer's board.


Yes - ST-Link  V2 should work!

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #287 on: August 16, 2017, 10:13:56 PM »
Again I took up radio modules.
I received two new radio modules.
Before that, one of the two radio modules I had broke.
Radio modules can be connected to two different ports - to the LCD port or to the sensor port.

I plan to do this: in the weapon, the radio module will be connected to the sensor port, and in the bandana to the LCD port.

If the radio module connected to the sensor port is already working, then in order to use the LCD port, you must disable the LCD driver.

With the existing project structure it is not easy to do this.
The main code is overloaded with low-level functions for working with hardware.

And since the equipment can be different (color or black and white LCD, for example), then there are many more macros.
The code became difficult to understand.

Of course - I, first of all - wanted to check the efficiency of my ideas as soon as possible, the quality of the code was in the background.
Now that the concept has generally justified itself, it's time to take up the quality of the code.

It is necessary to hide all low-level functions in the drivers.
Add a "middlware" layer to the interface so that there is a single interface for working with the connected devices and using the various devices, the code of the main program did not change.

This is such a difficult task...
« Last Edit: August 16, 2017, 10:21:34 PM by Pingvin »

berk

  • Veteran
  • *****
  • Posts: 375
    • View Profile
    • funwithelectrons.blogspot.com
Re: Open Source Laser Tag project - ARMada
« Reply #288 on: August 19, 2017, 03:52:57 AM »
You have just described what is known as a 'Hardware Abstraction Layer'. Shouldn't be too hard but if done properly a new piece of hardware should just drop straight in.

Good luck!

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #289 on: August 20, 2017, 06:18:09 AM »
You have just described what is known as a 'Hardware Abstraction Layer'. Shouldn't be too hard but if done properly a new piece of hardware should just drop straight in.

Good luck!
That's what I mean.
There are two types of screen, the initialization and text output functions are also different.
I want to make sure that the user who will write his code does not delve into the intricacies of the hardware implementation of the screen. It will be provided with an API for working with an abstract display.
Here is an example, so it was
Code: [Select]
bool configure_bluetooth(void)//настраиваем блютус модуль
{

bool at_res;
#ifdef COLOR_LCD
static volatile TextParamStruct TS;
TS.XPos =  0;
TS.YPos = 10;
TS.Size = 0;
TS.Font = StdFont;
TS.TxtCol = iWhite;//iGreen;//iRed;
TS.BkgCol =iBlack;//iWhite;
#endif


USART_DeInit(USART1);
InitCOM1(38400);
bt_set_at_commands_mode(true);
vTaskDelay(100);
bt_reset();
BL_ON;

at_res = send_test_at_command();
if(!at_res){
#ifndef COLOR_LCD
lcd8544_putstr(0, 8, "38400 тест не прошел", 0); // вывод первой строки
if (!screen_auto_refresh) lcd8544_dma_refresh(); // вывод буфера на экран ! без этого ничего видно не будет !
#else


if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
PStr("38400: Test error", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif
USART_DeInit(USART1);
InitCOM1(9600);
vTaskDelay(100);
}
if(strlen(armadaSystem.bluetooth.name))//если строка с именем не пустая
{

#ifndef COLOR_LCD
lcd8544_putstr(0, 16, "Имя: ", 0); // вывод первой строки
lcd8544_putstr(8, 16, armadaSystem.bluetooth.name, 0); // вывод первой строки
if (!screen_auto_refresh) lcd8544_dma_refresh(); //
#else
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
PStr( "Name: ", &TS);
PStr(armadaSystem.bluetooth.name, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif


at_res = send_set_at_command(at_name,armadaSystem.bluetooth.name);
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
if (at_res) PStr( "OK", &TS);
else PStr( "ERROR", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}

#else
if (at_res)
{

lcd8544_putstr(0, 24, "Имя успешно задано ", 0); // вывод первой строки
if (!screen_auto_refresh) lcd8544_dma_refresh(); //


}

#endif
}
if(strlen(armadaSystem.bluetooth.cmode))//если строка с именем не пустая
{
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
PStr( at_cmode, &TS);
PStr( "=", &TS);
PStr( armadaSystem.bluetooth.cmode, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif
at_res = send_set_at_command(at_cmode,armadaSystem.bluetooth.cmode);

#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
if (at_res) PStr( "OK", &TS);
else PStr( "ERROR", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif



}
if(strlen(armadaSystem.bluetooth.role))//если строка с именем не пустая
{
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
PStr( at_role, &TS);
PStr( "=", &TS);
PStr( armadaSystem.bluetooth.role, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif


at_res = send_set_at_command(at_role,armadaSystem.bluetooth.role);
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
if (at_res) PStr( "OK", &TS);
else PStr( "ERROR", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif



}
if(strlen(armadaSystem.bluetooth.mac_adress_for_bind))//если строка с именем не пустая
{

#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
PStr( "BIND:", &TS);
// PStr( "=", &TS);
PStr( armadaSystem.bluetooth.mac_adress_for_bind, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif
at_res = send_set_at_command(at_bind,armadaSystem.bluetooth.mac_adress_for_bind);
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
if (at_res) PStr( "OK", &TS);
else PStr( "ERROR", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif

}
if(strlen(armadaSystem.bluetooth.pswd))//если строка с именем не пустая
{
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
PStr( "PASSWORD:", &TS);
// PStr( "=", &TS);
PStr( armadaSystem.bluetooth.pswd, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif

at_res = send_set_at_command(at_pswd,armadaSystem.bluetooth.pswd);
#ifdef COLOR_LCD
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//если LCD занят, ждем 2 с
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.XPos =  0;
TS.YPos +=10;
if (at_res) PStr( "OK", &TS);
else PStr( "ERROR", &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif

}
bt_set_at_commands_mode(false);
USART_DeInit(USART1);
if(armadaSystem.bluetooth.baudrate) InitCOM1(armadaSystem.bluetooth.baudrate);
else InitCOM1(BAUDRATE);
bt_reset();
vTaskDelay(TIC_FQR*2);
#ifndef COLOR_LCD
BL_OFF;
#endif
}



It's terrible!
Unreadable!
Difficult to perceive!

Now this function looks like this
Code: [Select]


bool configure_bluetooth(void)//íàñòðàèâàåì áëþòóñ ìîäóëü
{

bool at_res;
unsigned char line_counter=0;
unsigned char line_on_screen=display_vertical_screen_resolution()/display_standard_symbol_height();


USART_DeInit(USART1);
InitCOM1(38400);
bt_set_at_commands_mode(true);
vTaskDelay(100);
bt_reset();
BL_ON;
display_put_string(0,line_counter++, "Set BT");

at_res = send_test_at_command();

if(!at_res){
if(!(line_counter<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}
display_put_string(0,display_standard_symbol_height()*(line_counter++),"38400: Test error");

USART_DeInit(USART1);
InitCOM1(9600);
vTaskDelay(100);
}
if(strlen(armadaSystem.bluetooth.name))//åñëè ñòðîêà ñ èìåíåì íå ïóñòàÿ
{

if(!((line_counter+1)<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}
at_res = send_set_at_command(at_name,armadaSystem.bluetooth.name);
display_put_string(0,display_standard_symbol_height()*(line_counter),"Name: ");
display_put_string(display_standard_symbol_width()*5,display_standard_symbol_height()*(line_counter++),armadaSystem.bluetooth.name);

if (at_res)
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"OK");
}
else
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"ERROR");
}
}
if(strlen(armadaSystem.bluetooth.cmode))//åñëè ñòðîêà ñ èìåíåì íå ïóñòàÿ
{

if(!((line_counter+1)<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}

at_res = send_set_at_command(at_cmode,armadaSystem.bluetooth.cmode);
display_put_string(0,display_standard_symbol_height()*(line_counter),at_cmode);
display_put_string(display_standard_symbol_width()*8,display_standard_symbol_height()*(line_counter),"=");
display_put_string(display_standard_symbol_width()*9,display_standard_symbol_height()*(line_counter++),armadaSystem.bluetooth.cmode);
if (at_res)
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"OK");
}
else
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"ERROR");
}
}
if(strlen(armadaSystem.bluetooth.role))//åñëè ñòðîêà ñ èìåíåì íå ïóñòàÿ
{
if(!((line_counter+1)<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}
at_res = send_set_at_command(at_role,armadaSystem.bluetooth.role);
display_put_string(0,display_standard_symbol_height()*(line_counter),at_role);
display_put_string(display_standard_symbol_width()*7,display_standard_symbol_height()*(line_counter),"=");
display_put_string(display_standard_symbol_width()*8,display_standard_symbol_height()*(line_counter++),armadaSystem.bluetooth.role);
if (at_res)
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"OK");
}
else
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"ERROR");
}
}
if(strlen(armadaSystem.bluetooth.mac_adress_for_bind))//åñëè ñòðîêà ñ èìåíåì íå ïóñòàÿ
{
if(!((line_counter+1)<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}
at_res = send_set_at_command(at_bind,armadaSystem.bluetooth.mac_adress_for_bind);
display_put_string(0,display_standard_symbol_height()*(line_counter),"BIND:");
display_put_string(display_standard_symbol_width()*5,display_standard_symbol_height()*(line_counter++),armadaSystem.bluetooth.mac_adress_for_bind);
if (at_res)
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"OK");
}
else
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"ERROR");
}
}
if(strlen(armadaSystem.bluetooth.pswd))//åñëè ñòðîêà ñ èìåíåì íå ïóñòàÿ
{

if(!((line_counter+1)<line_on_screen)){
vTaskDelay(150);
line_counter=0;
display_clear_screen();
}
at_res = send_set_at_command(at_pswd,armadaSystem.bluetooth.pswd);
display_put_string(0,display_standard_symbol_height()*(line_counter),"PASSWORD:");
display_put_string(display_standard_symbol_width()*9,display_standard_symbol_height()*(line_counter++),armadaSystem.bluetooth.pswd);
if (at_res)
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"OK");
}
else
{
display_put_string(0,display_standard_symbol_height()*(line_counter++),"ERROR");
}
}
bt_set_at_commands_mode(false);
GPIO_ResetBits(GPIOC, GPIO_Pin_4);//
USART_DeInit(USART1);
if(armadaSystem.bluetooth.baudrate) InitCOM1(armadaSystem.bluetooth.baudrate);
else InitCOM1(BAUDRATE);
// bt_reset();
vTaskDelay(TIC_FQR*2);
#ifndef COLOR_LCD
BL_OFF;
#endif
}

Now it works on both a color and black-and-white screen, the same code.
Even if I can connect another type of LCD, I do not need to change this code.
It looks a little better, does not it?
But the ideal is still far away.  ;) :)
« Last Edit: August 20, 2017, 06:35:53 AM by Pingvin »

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #290 on: August 20, 2017, 06:25:36 AM »
file display.h
Code: [Select]
#ifndef __DISPLAY_H
#define __DISPLAY_H
#include <stdio.h>
#include <stdint.h>

#include "cipher.h"
#include <GFXC.h>
#include "types.h"
#include "global_variables.h"

#ifndef COLOR_LCD
#define STANDARD_SYMBOL_HEIGHT 8
#define STANDARD_SYMBOL_WIDTH 6
#define HORIZONTAL_SCREEN_RESOLUTION 84
#define VERTICAL_SCREEN_RESOLUTION 48

#else
#define STANDARD_SYMBOL_HEIGHT 10
#define STANDARD_SYMBOL_WIDTH 6
#define HORIZONTAL_SCREEN_RESOLUTION 128
#define VERTICAL_SCREEN_RESOLUTION 128
#endif


void display_clear_screen(void);
void display_init(void);
// âûâîä ñòðîêè
void display_put_string(unsigned char x, unsigned char y, const unsigned char str[]);

unsigned char display_standard_symbol_height(void);
unsigned char display_standard_symbol_width(void);
unsigned char display_horizontal_screen_resolution(void);
unsigned char display_vertical_screen_resolution(void);

#endif



file display.c
Code: [Select]

#include "display.h"

void display_clear_screen(void){
#ifndef COLOR_LCD
clear_screen();
if (!screen_auto_refresh) lcd8544_dma_refresh(); // âûâîä áóôåðà íà ýêðàí ! áåç ýòîãî íè÷åãî âèäíî íå áóäåò !
#else
ClrScrn();
#endif
}


void display_init(void){
#ifndef COLOR_LCD
lcd8544_init(); // èíèöèàëèçàöèÿ ÷¸ðíî-áåëîãî äèñïëåÿ
#else

ILI9163Init();//
/*
drawBMP("2gun.bmp");
vTaskDelay((portTickType)(TIC_FQR*2));
*/

#endif


}


void display_put_string(unsigned char x, unsigned char y, const unsigned char str[]){

#ifndef COLOR_LCD
  lcd8544_putstr(x, y, str, 0); // âûâîä ïåðâîé ñòðîêè
  if (!screen_auto_refresh) lcd8544_dma_refresh(); // âûâîä áóôåðà íà ýêðàí ! áåç ýòîãî íè÷åãî âèäíî íå áóäåò !
#else
static volatile TextParamStruct TS;
if(xSemaphoreTake(xColorLCDSemaphore, (portTickType)(TIC_FQR*2)/*600*/ )== pdTRUE)//åñëè LCD çàíÿò, æäåì 2 ñ
{
while (!(SPI3->SR & SPI_SR_TXE)); // Wait for bus free
while (SPI3->SR & SPI_SR_BSY);
init_spi3();
SB(0x36, Reg); //Set Memory access mode
#if    LCD_MODUL_VERSION == 2
SB((0x08 |(1<<7)|(1<<6)), Dat);
#elif LCD_MODUL_VERSION == 1
SB((0x08 /*|(1<<7)*/), Dat);
#endif
TS.Size = 0;
TS.Font = StdFont;
TS.XPos =  (uint8_t)x;
TS.YPos = (uint8_t)y;
TS.TxtCol = iWhite;//iGreen;//iRed;
TS.BkgCol =iBlack;//iWhite;
PStr(/*"Set BT"*/str, &TS);
xSemaphoreGive(xColorLCDSemaphore);
}
#endif




}



unsigned char display_standard_symbol_height(void){

return (unsigned char) STANDARD_SYMBOL_HEIGHT;

}


unsigned char display_standard_symbol_width(void){
return (unsigned char) STANDARD_SYMBOL_WIDTH;

}


unsigned char display_horizontal_screen_resolution(void){
return HORIZONTAL_SCREEN_RESOLUTION;
}


unsigned char display_vertical_screen_resolution(void){
return VERTICAL_SCREEN_RESOLUTION;
}
« Last Edit: August 20, 2017, 06:37:20 AM by Pingvin »

Theuer

  • Full Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Open Source Laser Tag project - ARMada
« Reply #291 on: August 23, 2017, 12:03:16 PM »
 Hi Pingvin, I really need more some help...
 I had never had so many difficulties in an electronics project before.
 It's ridiculous, but I just do not understand how to connect the ST-Link V2 on the ARMADA CPU.
 ST-Link V2 have 10 Pins, (RST-SWDIO-GND-SWIM-SWCLK-3.3V-5V). How can I connect this on TX-RX ARMADA?
 Any ideia?
 Thanks buddy.

berk

  • Veteran
  • *****
  • Posts: 375
    • View Profile
    • funwithelectrons.blogspot.com
Re: Open Source Laser Tag project - ARMada
« Reply #292 on: August 23, 2017, 12:13:57 PM »
The professional way to do this is to do it at the link level. Create a library for the colour lcd, one for the monchrome one etc.
Each library exports the same API:
e.g.
InitDisplay()
ClearScreen();
OutputText() etc.

The display specific stuff is done inside the library but functionally it is the same. Commands like SetTextColour() are implemented but do nothing in the device libraries that do not support that function.

This way you don't pollute the core code with #ifdef DEVICE_A, you just see
InitDisplay()
and you know the device driver will sort it out for you.

Also, you can have as many different display devices (or others) as you like and your core code need never change.


Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #293 on: August 23, 2017, 09:30:37 PM »
The professional way to do this is to do it at the link level. Create a library for the colour lcd, one for the monchrome one etc.
Each library exports the same API:
e.g.
InitDisplay()
ClearScreen();
OutputText() etc.

The display specific stuff is done inside the library but functionally it is the same. Commands like SetTextColour() are implemented but do nothing in the device libraries that do not support that function.

This way you don't pollute the core code with #ifdef DEVICE_A, you just see
InitDisplay()
and you know the device driver will sort it out for you.

Also, you can have as many different display devices (or others) as you like and your core code need never change.

Thank you, berk, for participating!
Rewriting two libraries is an inadmissible luxury!
Too much time and effort will go away.
It's easier to make intermediate functions.
I get rid of #ifdef
Now all functions for working with the screen work with both drivers without #ifdef in the main program.

Code: [Select]

void display_clear_screen(void);
void display_init(void);
// вывод строки
void display_put_string(unsigned char x, unsigned char y, const unsigned char str[]);
void display_show_logo(void);
void display_show_guns_picture(void);
void display_show_bluetooth_icon(void);
void display_hide_bluetooth_icon(void);
void display_update_bluetooth_status(void);
void display_show_heart_picture(uint8_t picture_index);
void display_update_time(void);
void display_update_health(void);
void display_update_rounds(void);
void display_update_clips(void);
void display_update_battary_voltage(void);
void display_init_gui(void);
void display_update_fire_mode_status(void);
void display_backlight_off(void);
void display_backlight_on(void);
void display_show_game_over_picture(void);


unsigned char display_standard_symbol_height(void);
unsigned char display_standard_symbol_width(void);
unsigned char display_horizontal_screen_resolution(void);
unsigned char display_vertical_screen_resolution(void);


Here, for example - the task that will be responsible for the animation

Code: [Select]
void vTaskLED1(void *pvParameters) {
for (;;) {

if(!bt_configured)
    {
    continue;
    }

vTaskDelay(200);
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(0);
    xSemaphoreGive(xGameOverSemaphore);
    vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
    display_show_heart_picture(1);
    xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(2);
xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(3);
xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(2);
xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(1);
xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}
if(xSemaphoreTake(xGameOverSemaphore, (portTickType)(25))== pdTRUE )
{
display_show_heart_picture(0);
xSemaphoreGive(xGameOverSemaphore);
vTaskDelay(25);
}

#ifdef RTC_Enable
display_update_time();
#endif

display_update_battary_voltage();



            if (GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7) == 0){//если нет блютус соединения
            armadaSystem.wav_player.type_of_sound_to_play = SONAR;//надо воспроизвести звук сонара
            xSemaphoreGive(xWavPlayerManagerSemaphore);
            }
            else{
            if (armadaSystem.wav_player.type_of_sound_to_play == SONAR) armadaSystem.wav_player.type_of_sound_to_play=NOTHING;
            }
        }

}




Compare with what was!

In addition - I got rid of a lot of warnings when compiling a project
Soon I will update the repository.
« Last Edit: August 23, 2017, 09:34:10 PM by Pingvin »

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #294 on: August 23, 2017, 09:39:23 PM »
Hi Pingvin, I really need more some help...
 I had never had so many difficulties in an electronics project before.
 It's ridiculous, but I just do not understand how to connect the ST-Link V2 on the ARMADA CPU.
 ST-Link V2 have 10 Pins, (RST-SWDIO-GND-SWIM-SWCLK-3.3V-5V). How can I connect this on TX-RX ARMADA?
 Any ideia?
 Thanks buddy.


ST-Link connects to the SWD port.

Good luck!
I'm waiting for the good news from you! ;) :D
« Last Edit: August 23, 2017, 10:33:30 PM by Pingvin »

berk

  • Veteran
  • *****
  • Posts: 375
    • View Profile
    • funwithelectrons.blogspot.com
Re: Open Source Laser Tag project - ARMada
« Reply #295 on: August 24, 2017, 05:33:19 AM »
I agree it is a lot of work to convert existing code to libraries. If you go that way you really need to do it from the start. What
you have now is much cleaner!

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #296 on: August 29, 2017, 09:42:33 PM »
I will add support for the scripting language LSL (Lasertag Scripting Language)


I decided to start with a simple one - with an interpreter.
It seems that it should turn out.

Writing will be scripts for the handlers of various events: clicking on a button, changing the status of the bluetooth connection, receiving the infrared "shot", commands from the RC and so on.

Events can have parameters: the contents of the IR package, the console commands, the new connection status, and so on.
The necessary parameters will be accessible to the corresponding script-handlers.

There are also global variables responsible for the gameplay: the level of health, the number of rounds in the clip, the remainder of the clips, the weapon damage, etc.
They will also be visible.

Timers will be available with the ability to configure them from scripts - the direction of counting, the interval of counting.

In addition, not all commands need to be executed each time.
Initialization of the same timer must be done one time.
Therefore, there will be a separator of the initialization code, which will be executed only once, and a cyclic code.
For example, the LOOP delimiter:

There will be comparison commands.
There will be a grouping of the command block with curly brackets.
# Is comments, lines will be ignored

While everything seems to be on the way, it will be seen what to add.

With the delimiters of the teams it was not decided.
Simpler, of course: one line - one command.
But I can make the command delimiter a semicolon.


For example, you need to issue two clips to anyone who shoots at the device.
But not more often than once every two minutes.

An example of a script (Handler of the received infrared packet).

countdown_timer_down_to 0
timestamp_counting_interval 1
LOOP:

if_timer_is_reset
{
send_add_clips 2
set_timer_value 120
reproduce_sound_ok
quit
}
reproduce_sound_error

ENDLOOP

Issue clips only their own

countdown_timer_down_to 0
timestamp_counting_interval 1
LOOP:

if_timer_is_reset
{
If_equals team_color_in_package, my_team_color
{
send_add_clips 2
set_timer_value 120
reproduce_sound_ok
quit
}
reproduce_sound_error
quit
}
reproduce_sound_error

ENDLOOP





The scripts will be on the SD card or broadcast on the radio channel.
« Last Edit: August 29, 2017, 10:06:08 PM by Pingvin »

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #297 on: August 30, 2017, 07:51:18 AM »
New PCB for new device
« Last Edit: August 30, 2017, 10:52:03 AM by Pingvin »

Pingvin

  • Developer
  • Veteran
  • ***
  • Posts: 427
    • View Profile
Re: Open Source Laser Tag project - ARMada
« Reply #298 on: August 31, 2017, 10:06:37 AM »
ARMada. Si4432 Driver InThe Main Firmware.
https://www.youtube.com/watch?v=PNboULEzN1g

Theuer

  • Full Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Open Source Laser Tag project - ARMada
« Reply #299 on: September 13, 2017, 11:31:22 PM »
  Finally I got the first Boot on ARMADA!

 What are the names of all PCB pins?
  I did not understand some things like 4 pins for TDA amp.
  I also do not understand where are the image files of the boot without SD card, where is that photo of the weapons with black background?

  Thank you, I am very pleased to see progress again.
« Last Edit: September 14, 2017, 08:57:34 AM by Theuer »