|
|
#include "tgz2Window.h"
#include "../../source/lib/hardware/soc/modules/pru/pru_ss.h"
tgz2Window::tgz2Window( protocolTGZ *Device ) : WindowCLI( NULL ){ m_pDeviceProtocol = Device; m_x = 3; m_y = 3; m_w = 40; m_h = 17; #ifdef NEWT_CLI
m_l1 = newtLabel( 3, 1, "Bytes: 3 2 1 0"); m_l2 = newtLabel( 3, 2, "Data : 00 00 00 00"); m_l3 = newtLabel( 3, 3, " MSB --- LSB"); m_t1 = newtTextbox( 10, 2, 11, 1, 0 ); m_l4 = newtLabel( 3, 4, "M-Motors: pulses/sec."); m_t2 = newtTextbox( 14, 4, 6, 1, 0 ); m_l5 = newtLabel( 3, 5, "M-Motors: spins/sec."); m_t3 = newtTextbox( 14, 5, 5, 1, 0 ); m_l6 = newtLabel( 3, 6, "B-Motors: pulses/sec."); m_t4 = newtTextbox( 14, 6, 6, 1, 0 ); m_l7 = newtLabel( 3, 7, "B-Motors: spins/sec."); m_t5 = newtTextbox( 14, 7, 5, 1, 0 ); m_l8 = newtLabel( 3, 8, "Flags: Start[ ] Reset Error[ ]"); m_t6 = newtTextbox( 16, 8, 1, 1, 0 ); m_t7 = newtTextbox( 31, 8, 1, 1, 0 ); m_oMenu = newtListbox( 3, 10, 6, NEWT_FLAG_RETURNEXIT | NEWT_FLAG_SCROLL ); newtListboxAppendEntry( m_oMenu, "Toggle Start/Stop", (void *) 1 ); newtListboxAppendEntry( m_oMenu, "Toggle Reset-Error", (void *) 2 ); newtListboxAppendEntry( m_oMenu, "Toggle Mirror Motor Speed",(void *) 3 ); newtListboxAppendEntry( m_oMenu, "Toggle Base Motor Speed", (void *) 4 ); newtListboxAppendEntry( m_oMenu, "Send CMD to TGZ", (void *) 5 ); newtListboxAppendEntry( m_oMenu, "EXIT", (void *) 255 ); newtFormAddComponents( m_oForm, m_l1, m_l2, m_l3, m_l4, m_l5, m_l6, m_l7, m_l8, m_t1, m_t2, m_t3, m_t4, m_t5, m_t6, m_t7, m_oMenu, NULL ); #else
create( 0, 18, 40, 17 ); #endif
};
tgz2Window::~tgz2Window(){ newtPopWindow();};int tgz2Window::decodeEvent( newtComponent evt ){ if( evt == m_oMenu ) { void *selected; selected = newtListboxGetCurrent( m_oMenu ); return ( int )selected; }; return 0;};
void tgz2Window::paint( void ){ #ifdef NEWT_CLI
newtCenteredWindow( m_w, m_h, "TGZ New Protocol" ); if( m_pDeviceProtocol != NULL ) { char tBuffer[245]; m_dwMyStatus = m_pDeviceProtocol->getPreparing(); m_dwTGZStatus = m_pDeviceProtocol->getLastReceived(); sprintf( tBuffer, "%02X %02X %02X %02X", ((m_dwMyStatus >> 24 )& 0xFF),((m_dwMyStatus >> 16 )& 0xFF),((m_dwMyStatus >> 8 )& 0xFF),( m_dwMyStatus & 0xFF) ); newtTextboxSetText( m_t1, tBuffer ); sprintf( tBuffer, "%d", ( m_pDeviceProtocol->getQSpeed() << 2 ) ); newtTextboxSetText( m_t2, tBuffer ); sprintf( tBuffer, "%0.2f",(float)( m_pDeviceProtocol->getQSpeed() << 2 ) / 8192.f ); newtTextboxSetText( m_t3, tBuffer ); sprintf( tBuffer, "%d", ( m_pDeviceProtocol->getBSpeed() << 4 ) ); newtTextboxSetText( m_t4, tBuffer ); sprintf( tBuffer, "%0.2f", (float)( m_pDeviceProtocol->getBSpeed() << 4 ) / 94208.f ); newtTextboxSetText( m_t5, tBuffer ); sprintf( tBuffer, "%c",(m_pDeviceProtocol->getRunFlag()?'*':' ')); newtTextboxSetText( m_t6, tBuffer ); sprintf( tBuffer, "%c",(m_pDeviceProtocol->getResetFlag()?'*':' ')); newtTextboxSetText( m_t7, tBuffer ); } newtDrawForm( m_oForm ); #else
createBox( true ); mvwprintw( m_pWND, 2,2, " TGZ Communication " ); if( m_pDeviceProtocol != NULL ) { m_dwMyStatus = m_pDeviceProtocol->getPreparing(); m_dwTGZStatus = m_pDeviceProtocol->getLastReceived(); mvwprintw( m_pWND, 3,2, " Frame 0x200 output: \t%08X", m_dwMyStatus ); mvwprintw( m_pWND, 4,2, " Control Byte: \t0x%02X [%s%s]", (m_dwMyStatus & 0xFF),((m_dwMyStatus & 0xFF)&2)?"Run":"Stp",((m_dwMyStatus & 0xFF)&1)?",RstErr":""); mvwprintw( m_pWND, 5,2, " PRF: \t\t%d kHz", ((m_dwMyStatus >> 8) & 0xFF) ); mvwprintw( m_pWND, 6,2, " Block Cycles: \t%d", ((m_dwMyStatus >> 16) & 0xFF) ); mvwprintw( m_pWND, 7,2, " PRF Divider: \t%d", ((m_dwMyStatus >> 24) & 0xFF) ); mvwprintw( m_pWND, 8,2, " Frame 0x201 input: \t%08X", m_dwTGZStatus ); mvwprintw( m_pWND, 9,2, " Status Byte: \t0x%02X [%s%s%s]", (m_dwTGZStatus & 0xFF), ((m_dwTGZStatus & 0xFF)&4)?"Sync":"nSync",((m_dwTGZStatus & 0xFF)&2)?",Run":"",((m_dwTGZStatus & 0xFF)&1)?",Rdy":",Stb" ); mvwprintw( m_pWND, 10,2, " PRF: \t\t%d kHz", ((m_dwTGZStatus >> 8) & 0xFF) ); mvwprintw( m_pWND, 11,2, " Block Cycles: \t%d", ((m_dwTGZStatus >> 16) & 0xFF) ); mvwprintw( m_pWND, 12,2, " PRF Divider: \t%d", ((m_dwTGZStatus >> 24) & 0xFF) ); if( (((m_dwMyStatus & 0xFF)&2)== 0 ) && ((( m_dwTGZStatus & 0xFF)&2)== 0 ) ) { mvwprintw( m_pWND, 15,2, " [Available to Config]" ); } else { mvwprintw( m_pWND, 15,2, " [Config is Disabled]" ); } } else { mvwprintw( m_pWND, 3,2, " Not Init" ); } wrefresh( m_pWND ); #endif
};
|