You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "gpioWindow.h"
  2. gpioWindow::gpioWindow() : WindowCLI(NULL){
  3. m_x = 1;
  4. m_y = 18;
  5. m_w = 80;
  6. m_h = 17;
  7. #ifdef NEWT_CLI
  8. m_t1 = newtTextbox( 2, 1, 60, 1, 0 );
  9. m_t2 = newtTextbox( 2, 2, 60, 1, 0 );
  10. m_t3 = newtTextbox( 2, 3, 60, 1, 0 );
  11. m_t4 = newtTextbox( 2, 4, 60, 1, 0 );
  12. m_t5 = newtTextbox( 2, 5, 60, 1, 0 );
  13. m_t6 = newtTextbox( 2, 6, 60, 1, 0 );
  14. newtFormAddComponents( m_oForm, m_t1, m_t2, m_t3, m_t4, m_t5, m_t6, NULL );
  15. #else
  16. //create( 41, 18, 80, 17 );
  17. create( 1, 18, 80, 17 );
  18. #endif
  19. };
  20. gpioWindow::~gpioWindow(){
  21. newtPopWindow();
  22. };
  23. void gpioWindow::paint( void ){
  24. char tBuffer[245];
  25. m_nGPI0 = getInputsGPIO(0);
  26. m_nGPI1 = getInputsGPIO(1);
  27. m_nGPI2 = getInputsGPIO(2);
  28. m_nGPI3 = getInputsGPIO(3);
  29. m_nGPI4 = getInputsGPIO(4);
  30. m_nGPI5 = getInputsGPIO(5);
  31. m_nGPO0 = getOutputsGPIO(0);
  32. m_nGPO1 = getOutputsGPIO(1);
  33. m_nGPO2 = getOutputsGPIO(2);
  34. m_nGPO3 = getOutputsGPIO(3);
  35. m_nGPO4 = getOutputsGPIO(4);
  36. m_nGPO5 = getOutputsGPIO(5);
  37. #ifdef NEWT_CLI
  38. newtCenteredWindow( m_w, m_h, "GPIO Info" );
  39. sprintf( tBuffer, "GPIO[0] Input:\t0x%08x\tGPIO[0] Output:\t0x%08x", m_nGPI0, m_nGPO0 );
  40. newtTextboxSetText( m_t1, tBuffer );
  41. sprintf( tBuffer, "GPIO[1] Input:\t0x%08x\tGPIO[1] Output:\t0x%08x", m_nGPI1, m_nGPO1 );
  42. newtTextboxSetText( m_t2, tBuffer );
  43. sprintf( tBuffer, "GPIO[2] Input:\t0x%08x\tGPIO[2] Output:\t0x%08x", m_nGPI2, m_nGPO2 );
  44. newtTextboxSetText( m_t3, tBuffer );
  45. sprintf( tBuffer, "GPIO[3] Input:\t0x%08x\tGPIO[3] Output:\t0x%08x", m_nGPI3, m_nGPO3 );
  46. newtTextboxSetText( m_t4, tBuffer );
  47. sprintf( tBuffer, "GPIO[4] Input:\t0x%08x\tGPIO[4] Output:\t0x%08x", m_nGPI4, m_nGPO4 );
  48. newtTextboxSetText( m_t5, tBuffer );
  49. sprintf( tBuffer, "GPIO[5] Input:\t0x%08x\tGPIO[5] Output:\t0x%08x", m_nGPI5, m_nGPO5 );
  50. newtTextboxSetText( m_t6, tBuffer );
  51. newtDrawForm( m_oForm );
  52. newtRefresh();
  53. #else
  54. createBox( true );
  55. uint32_t KAKA = findInterleave();
  56. mvwprintw( m_pWND, 2,2,"--- MOTOR STATUS ---" );
  57. if( tTUPUS != NULL ) {
  58. cur_P2P_HM = tTUPUS->HOST_data;
  59. if( cur_P2P_HM < min_P2P_HM ) min_P2P_HM = cur_P2P_HM;
  60. if( cur_P2P_HM > max_P2P_HM ) max_P2P_HM = cur_P2P_HM;
  61. cur_P2P_VM = tTUPUS->PRU_data;
  62. if( cur_P2P_VM < min_P2P_VM ) min_P2P_VM = cur_P2P_VM;
  63. if( cur_P2P_VM > max_P2P_VM ) max_P2P_VM = cur_P2P_VM;
  64. mvwprintw( m_pWND, 3,2,"Signature:\t0x%08x", tTUPUS->PRU_id );
  65. mvwprintw( m_pWND, 4,2,"Host status:\t0x%08x Interleave:%d", tTUPUS->HOST_status, KAKA );
  66. mvwprintw( m_pWND, 5,2,"Host cmd:\t0x%08x", tTUPUS->HOST_command );
  67. mvwprintw( m_pWND, 6,2,"Motor Status: %s", (( tTUPUS->PRU_status & 0xFF000000)?"Synced":"Not Synced"));
  68. mvwprintw( m_pWND, 7,2,"Vertical Pulses per Rotation:\t%08d", tTUPUS->PRU_address );
  69. mvwprintw( m_pWND, 8,2,"Horizontal Pulses per Rotation:\t%08d", tTUPUS->HOST_address );
  70. mvwprintw( m_pWND, 9,2,"Horizontal Freq:\t%.2f kHz. Max: %.2f Min: %.2f",
  71. 1000000.0/( cur_P2P_HM * 5.0 ),
  72. 1000000.0/( min_P2P_HM * 5.0 ),
  73. 1000000.0/( max_P2P_HM * 5.0 )
  74. );
  75. mvwprintw( m_pWND, 10,2,"Vertical Freq:\t%.2f kHz. Max: %.2f Min: %.2f",
  76. 1000000.0/( cur_P2P_VM * 5.0 ),
  77. 1000000.0/( min_P2P_VM * 5.0 ),
  78. 1000000.0/( max_P2P_VM * 5.0 )
  79. );
  80. mvwprintw( m_pWND, 12,2,"Stat File:\tNot Started Yet" );
  81. mvwprintw( m_pWND, 13,2,"Harvesting Stat:\tNot Started Yet" );
  82. mvwprintw( m_pWND, 14,2,"Harvesting Status:\t\t\t." );
  83. tTUPUS->HOST_status = 0;
  84. } else {
  85. mvwprintw( m_pWND, 3,2,"Not Initialized");
  86. };
  87. wrefresh( m_pWND );
  88. #endif
  89. };