Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T1192 : 1 line bug fix in Visualizer, and setup timer for average frame rate measurement in firmware #42

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AXIOM_Remote_Firmware_Visualizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ FILE(GLOB GL3W_SOURCES "${CMAKE_SOURCE_DIR}/3rdParty/gl3w/GL/gl3w.c")
FILE(GLOB FIRMWARE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Painter/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Screens/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/UI/Widgets/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/Attribute.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/CentralDB.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/../Firmware/CentralDB/CentralDBObserver.cpp"
Expand Down
39 changes: 34 additions & 5 deletions Firmware/Main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <xc.h>
#include <sys/attribs.h>

// Configuration
#include "Configuration/PIC32.h"

Expand Down Expand Up @@ -28,6 +31,7 @@
// Defined in procdefs.ld
volatile extern uint16_t framebuffer[ILI9341_TFTWIDTH * ILI9341_TFTHEIGHT];
ILI9341Display display(framebuffer);
uint8_t fps = 0, frames = 0;

void ConfigGPIO()
{
Expand All @@ -44,6 +48,9 @@ void InitPBUS(void)
PB7DIVbits.PBDIV = 0b000000; // divide by 1
PB7DIVbits.ON = 1;

PB3DIVbits.PBDIV = 13; // divide by 12, 192Mhz/12 = 16Mhz
PB3DIVbits.ON = 1;

CFGCONbits.OCACLK = 1;
TRISDbits.TRISD10 = 0;
RPD10R = 0b1100;
Expand Down Expand Up @@ -532,8 +539,31 @@ void init_uart2()
irq_enable();
}

int main()
//ISR
extern "C" void __ISR(_TIMER_2_VECTOR, IPL7SOFT) Timer2_ISR(void)
{
fps = frames;
frames = 0;
IFS0bits.T2IF = 0; //clear flag
}

void InitTimer2()
{
T2CONbits.TCS = 0; //Internal Clock
T2CONbits.TCKPS = 0b111; //1:256 Prescale value
TMR2 = 0; //Value of timer 2
PR2 = 62500; // (62500/16Mhz)x256 = 1
T2CONbits.ON = 1;

//Timer 2 Interrupt
IPC2bits.T2IP = 7;
IPC2bits.T2IS = 0;
IFS0bits.T2IF = 0;
IEC0bits.T2IE = 1;
}

int main()
{
USBCDCDevice cdcDevice;

Setup(display, cdcDevice);
Expand Down Expand Up @@ -589,17 +619,16 @@ int main()

// init_uart2();

uint16_t counter = 0;
InitTimer2();
while (1)
{
cdcDevice.Process();

menuSystem.Update(PollButtons(&cdcDevice), PollKMW(&cdcDevice));

menuSystem.Draw(painter);

counter++;
sprintf(debugText, "%d\r\n", counter);
frames++;
sprintf(debugText, "%d\r\n", fps);
painter->DrawText(3, 90, debugText, (uint16_t)Color565::Red, TextAlign::TEXT_ALIGN_LEFT, 0);

// painter.DrawFillRoundRectangle(50, 120, 100, 40, 5, (uint16_t)Color565::Black);
Expand Down