Example #1
0
// M1 left
// M2 right
void motorInit(){
  // Keep pins low if unused.
  set_outputs(M1reverse, M1enable, 0b0000);
  set_outputs(M2reverse, M2enable, 0b0000);
  set_directions(M1reverse, M1enable, 0b1111);
  set_directions(M2reverse, M2enable, 0b1111);

}  
int getQTIs(int highPin, int lowPin)           // Function - getQTIs
{
  int dt = (CLKFREQ / 1000000) * 230;          // Set up 230 us time increment
  set_outputs(highPin, lowPin, 0b1111);        // highPin...lowPin set high
  set_directions(highPin, lowPin, 0b1111);     // highPin...lowPin set to output
  waitcnt(dt + CNT);                           // Wait 230 us
  set_directions(highPin, lowPin, 0b0000);     // highPin...lowPin st to input
  waitcnt(dt + CNT);                           // Wait 230 us
  int qtis = get_states(highPin, lowPin);      // Get 4-bit pattern QTIs apply
  return qtis;                                 // Return val containing pattern
}
Example #3
0
/***********************************************************************//**
 * @brief Constructor
 *
 * @param[in] map Sky map.
 * @param[in] weights Event cube weights.
 * @param[in] ebds Energy boundaries.
 * @param[in] gti Good Time intervals.
 *
 * Constructs instance of events cube from a sky map, a map of weights,
 * energy boundaries and Good Time Intervals.
 ***************************************************************************/
GCTAEventCube::GCTAEventCube(const GSkyMap&  map,
                             const GSkyMap&  weights,
                             const GEbounds& ebds,
                             const GGti&     gti) : GEventCube()
{
    // Initialise members
    init_members();

    // Set sky map, energy boundaries and GTI
    m_map = map;
    this->ebounds(ebds);
    this->gti(gti);

    // Set weight map
    m_weights = weights;

    // Set sky directions
    set_directions();

    // Set energies
    set_energies();

    // Set times
    set_times();

    // Return
    return;
}
Example #4
0
/***********************************************************************//**
 * @brief Read Fermi/LAT counts map from HDU.
 *
 * @param[in] hdu Image HDU.
 *
 * This method reads a Fermi/LAT counts map from a FITS image. The counts map
 * is stored in a GSkyMap object, and a pointer is set up to access the
 * pixels individually. Recall that skymap pixels are stored in the order
 * (ix,iy,ebin).
 ***************************************************************************/
void GLATEventCube::read_cntmap(const GFitsImage& hdu)
{
    // Load counts map as sky map
    m_map.read(hdu);

    // Set sky directions
    set_directions();

    // Return
    return;
}
Example #5
0
/***********************************************************************//**
 * @brief Set event cube from sky map
 ***************************************************************************/
void GLATEventCube::map(const GSkyMap& map)
{
    // Store sky map
    m_map = map;

    // Compute sky directions
    set_directions();

    // Return
    return;
}
Example #6
0
/***********************************************************************//**
 * @brief Set event cube counts from sky map
 *
 * @param[in] counts Event cube counts sky map.
 *
 * Sets event cube counts from sky map. The methods also sets all weights to
 * unity.
 ***************************************************************************/
void GCTAEventCube::counts(const GSkyMap& counts)
{
    // Store sky map
    m_map = counts;

    // Compute sky directions
    set_directions();

    // Set all weights to unity
    m_weights = m_map;
    m_weights = 1.0;

    // Return
    return;
}
Example #7
0
/***********************************************************************//**
 * @brief Read CTA counts map from HDU.
 *
 * @param[in] hdu Pointer to image HDU.
 *
 * This method reads a CTA counts map from a FITS HDU. The counts map is
 * stored in a GSkymap object.
 ***************************************************************************/
void GCTAEventCube::read_cntmap(const GFitsImage* hdu)
{
    // Continue only if HDU is valid
    if (hdu != NULL) {

        // Load counts map as sky map
        m_map.read(hdu);

        // Set sky directions
        set_directions();

    } // endif: HDU was valid

    // Return
    return;
}
Example #8
0
/**
 *  Initialize the LCD interface.  The LCD uses negative logic, so we need
 *  to set various pins high.
 *
 *  TODO document the config options better and optimize
 */
void LCD_Init(void) {

    // Set pins as output
    set_direction(LCD_RST, 1);
    set_direction(LCD_CS, 1);
    set_direction(LCD_RS, 1);
    set_direction(LCD_WR, 1);
    set_direction(LCD_RD, 1);

    // Reset the display
    set_output(LCD_RST, 1);
    pause(5);
    set_output(LCD_RST, 0);
    pause(10);
    set_output(LCD_RST, 1);

    // Set the pins high
    set_output(LCD_CS, 1);
    set_output(LCD_RS, 1);
    set_output(LCD_WR, 1);
    set_output(LCD_RD, 1);

    set_directions(7, 0, 0xFF);

    LCD_SyncTransfer();

    // Soft reset
    LCD_Write(LCD_SOFTWARE_RESET,           0x0001);
    pause(1);
    LCD_Write(LCD_SOFTWARE_RESET,           0x0000);


    LCD_Write(LCD_BASE_IMAGE_NB_LINE,       0x6200);
    LCD_Write(LCD_DISPLAY_CONTROL_2,        0x0808);

    // Gamma correction
    LCD_Write(LCD_GAMMA_CONTROL_1,          0x0C00);
    LCD_Write(LCD_GAMMA_CONTROL_2,          0x5A0B);
    LCD_Write(LCD_GAMMA_CONTROL_3,          0x0906);
    LCD_Write(LCD_GAMMA_CONTROL_4,          0x1017);
    LCD_Write(LCD_GAMMA_CONTROL_5,          0x2300);
    LCD_Write(LCD_GAMMA_CONTROL_6,          0x1700);
    LCD_Write(LCD_GAMMA_CONTROL_7,          0x6309);
    LCD_Write(LCD_GAMMA_CONTROL_8,          0x0C09);
    LCD_Write(LCD_GAMMA_CONTROL_9,          0x100C);
    LCD_Write(LCD_GAMMA_CONTROL_10,         0x2232);

    /*
     LCD_Write(LCD_PANEL_IF_CONTROL_1,       0x0016);    // Clocks per line, osc divisor
     LCD_Write(LCD_PANEL_IF_CONTROL_2,       0x0101);
     LCD_Write(LCD_PANEL_IF_CONTROL_3,       0x0000);
     LCD_Write(LCD_PANEL_IF_CONTROL_4,       0x0001);
    */

    // Power control
    LCD_Write(LCD_POWER_CONTROL_1,          0x0330);      //BT,AP
    LCD_Write(LCD_POWER_CONTROL_2,          0x0237);      //DC0,DC1,VC
    LCD_Write(LCD_POWER_CONTROL_4,          0x0D00);      //VDV
    LCD_Write(LCD_NVM_DATA_RW,              0x6100);      //VCM
    LCD_Write(LCD_POWER_CONTROL_3,          0xC1B0);      //VRH,VCMR,PSON,PON
    pause(50);

//  LCD_Write(LCD_DRIVER_OUTPUT_CONTROL,    0x0100);
    LCD_Write(LCD_LCD_DRIVE_WAVE_CONTROL,   0x0100);       // B[8]    Line inversion
    LCD_Write(LCD_ENTRY_MODE,               0x5030);       // B[3]    Address counter goes horizontal
    // B[5:4]  Horizontal decrement, vertical increment
    // B[7]    Orgin not moved
    // B[12]   Write data in BGR mode
    // B[14]   16bpp
    // B[15]   Two transfers per 16 bits
//  LCD_Write(LCD_EXT_DISPLAY_IF_CONTROL_1, 0x0001);       // B[0]    16 bit color
    // B[5:4]  Internal clock
    // B[8]    RAM can be accessed while doing display
    // B[14:12]RAM write cycle is 1 frame
    LCD_Write(LCD_FRAME_MARKER_CONTROL,     0x8000);
//  LCD_Write(LCD_EXT_DISPLAY_IF_CONTROL_2, 0x0000);

    LCD_Write(LCD_WIN_H_RAM_ADRR_START,     0x0000);
    LCD_Write(LCD_WIN_H_RAM_ADRR_END,       0x00EF);
    LCD_Write(LCD_WIN_V_RAM_ADRR_START,     0x0000);
    LCD_Write(LCD_WIN_V_RAM_ADRR_END,       0x018F);       //432=01AF,400=018F
    LCD_Write(0x0500, 0x0000);
    LCD_Write(0x0501, 0x0000);
    LCD_Write(0x0502, 0x005F);
    LCD_Write(LCD_BASE_IMAGE_DISPLAY_CTRL,  0x0001);
    LCD_Write(LCD_BASE_IMAGE_V_SCROLL_CTRL, 0x0000);
    pause(50);

    LCD_Write(LCD_DISPLAY_CONTROL_1,        0x0100);         //BASEE
    pause(50);

    LCD_Write(LCD_RAM_ADRR_SET_H,           0x0000);
    LCD_Write(LCD_RAM_ADRR_SET_V,           0x0000);
    LCD_Write_Command(LCD_RAM_RW);



}