Esempio n. 1
0
void dashboardInit(void)
{
    static busDevice_t dashBoardBus;
    dashBoardBus.i2c.device = I2C_CFG_TO_DEV(dashboardConfig()->device);
    dashBoardBus.i2c.address = dashboardConfig()->address;
    bus = &dashBoardBus;

    delay(200);
    resetDisplay();
    delay(200);

    displayPort = displayPortOledInit(bus);
#if defined(CMS)
    if (dashboardPresent) {
        cmsDisplayPortRegister(displayPort);
    }
#endif

    memset(&pageState, 0, sizeof(pageState));
    dashboardSetPage(PAGE_WELCOME);

    uint32_t now = micros();
    dashboardUpdate(now);

    dashboardSetNextPageChangeAt(now + PAGE_CYCLE_FREQUENCY);
}
void displayInit(void)
{
	// SPI Variables
	config.CS_HOLD = false;
	config.WDEL = true;
	config.DFSEL = SPI_FMT_0;
	config.CSNR = 0x00;

	// Sets up the environment
	_enable_IRQ(); // This enables interrupts
	rtiEnableNotification(rtiNOTIFICATION_COMPARE0); // This enables the Real Time Interrupt notification

	// Powers up the display
	gioSetBit(hetPORT1, VCCPIN, 1);

	// Resets the display
	resetDisplay();

	// Initialization commands
	writeData(0x21, commandData); // Extended instruction set control
	writeData(0xB8, commandData); //Set LCD Vop (Contrast)
	writeData(0x04, commandData); //Set Temp coefficent
	writeData(0x14, commandData); //LCD bias mode 1:48 (try 0x13)
	//We must send 0x20 before modifying the display control mode
	writeData(0x20, commandData);
	writeData(0x0C, commandData); //Set display control, normal mode.

	// Clears the display buffer variable
	clearBuffer(WHITE);
}
Esempio n. 3
0
/**
 * Handles screen key shortcuts.
 * @param action Pointer to an action.
 */
void Screen::handle(Action *action)
{
	if (Options::debug)
	{
		if (action->getDetails()->type == SDL_KEYDOWN && action->getDetails()->key.keysym.sym == SDLK_F8)
		{
			switch(Timer::gameSlowSpeed)
			{
				case 1: Timer::gameSlowSpeed = 5; break;
				case 5: Timer::gameSlowSpeed = 15; break;
				default: Timer::gameSlowSpeed = 1; break;
			}				
		}
	}
	
	if (action->getDetails()->type == SDL_KEYDOWN && action->getDetails()->key.keysym.sym == SDLK_RETURN && (SDL_GetModState() & KMOD_ALT) != 0)
	{
		Options::fullscreen = !Options::fullscreen;
		resetDisplay();
	}
	else if (action->getDetails()->type == SDL_KEYDOWN && action->getDetails()->key.keysym.sym == Options::keyScreenshot)
	{
		std::ostringstream ss;
		int i = 0;
		do
		{
			ss.str("");
			ss << Options::getMasterUserFolder() << "screen" << std::setfill('0') << std::setw(3) << i << ".png";
			i++;
		}
		while (CrossPlatform::fileExists(ss.str()));
		screenshot(ss.str());
		return;
	}
}
Esempio n. 4
0
void restoreDefaultAll()
    {
           resetDisplay();
           AnalogInputs::restoreDefault();
           ProgramData::restoreDefault();
           Settings::restoreDefault();
    }
DashboardLayer* dashboard_layer_create(GRect frame, GColor bgColor){
	DashboardLayer* dashboard_layer = malloc(sizeof(DashboardLayer));

	dashboard_layer->bgColor = bgColor;
	dashboard_layer->fgColor = gcolor_equal(bgColor,GColorBlack) ? GColorWhite : GColorBlack;

#ifdef PBL_SDK_3
	dashboard_layer->main_font = fonts_get_system_font(FONT_KEY_LECO_36_BOLD_NUMBERS);
#else
	dashboard_layer->main_font = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);
#endif

	resetDisplay(dashboard_layer);
	
	// s_background
	dashboard_layer->s_background = layer_create_with_data(frame, sizeof(DashboardLayer*));
	layer_set_update_proc(dashboard_layer->s_background, cb_background_draw);
	memcpy(layer_get_data(dashboard_layer->s_background), &dashboard_layer, sizeof(DashboardLayer*));
	
	// s_name
	dashboard_layer->s_name = text_layer_create(GRect(0, 4, 144, 20));
	text_layer_set_background_color(dashboard_layer->s_name, GColorClear);
	text_layer_set_font(dashboard_layer->s_name, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	text_layer_set_text_color(dashboard_layer->s_name, dashboard_layer->fgColor);
	text_layer_set_text(dashboard_layer->s_name, dashboard_layer->text_name);
	text_layer_set_text_alignment(dashboard_layer->s_name, GTextAlignmentCenter);
	layer_add_child(dashboard_layer->s_background, text_layer_get_layer(dashboard_layer->s_name));
	
	// s_main
#ifdef PBL_SDK_3
	dashboard_layer->s_main = text_layer_create(GRect(0, 19, 144, 45));
#else
	dashboard_layer->s_main = text_layer_create(GRect(0, 15, 144, 45));
#endif
	text_layer_set_font(dashboard_layer->s_main, dashboard_layer->main_font);
	text_layer_set_background_color(dashboard_layer->s_main, GColorClear);
	text_layer_set_text_color(dashboard_layer->s_main, dashboard_layer->fgColor);
	text_layer_set_text(dashboard_layer->s_main, dashboard_layer->text_main);
	text_layer_set_text_alignment(dashboard_layer->s_main, GTextAlignmentCenter);
	layer_add_child(dashboard_layer->s_background, text_layer_get_layer(dashboard_layer->s_main));

	// s_subtitle
	dashboard_layer->s_subtitle = text_layer_create(GRect(0, 60, 144, 27));
	text_layer_set_background_color(dashboard_layer->s_subtitle, GColorClear);
	text_layer_set_text_color(dashboard_layer->s_subtitle, dashboard_layer->fgColor);
	text_layer_set_text(dashboard_layer->s_subtitle, dashboard_layer->text_subtitle);
	text_layer_set_text_alignment(dashboard_layer->s_subtitle, GTextAlignmentCenter);
	text_layer_set_font(dashboard_layer->s_subtitle, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
	layer_add_child(dashboard_layer->s_background, text_layer_get_layer(dashboard_layer->s_subtitle));

	// s_graph_layer
	dashboard_layer->s_graph_layer = graph_layer_create(GRect(3, 80, 144 - 6, 168 - 80), dashboard_layer->fgColor);
	layer_add_child(dashboard_layer->s_background, graph_layer_get_layer(dashboard_layer->s_graph_layer));

	return dashboard_layer;	
}
Esempio n. 6
0
void handlePageChange(void)
{
    // Some OLED displays do not respond on the first initialisation so refresh the display
    // when the page changes in the hopes the hardware responds.  This also allows the
    // user to power off/on the display or connect it while powered.
    resetDisplay();

    i2c_OLED_clear_display_quick();
    showTitle();
}
Esempio n. 7
0
    void calibrationDisplaymessage(bool calib, bool force)
    {
        if(force)
            resetDisplay();
            Timer::delay(2000);

        if(calib)
            Screen::runCalibrateBeforeUse();
    
    }
Esempio n. 8
0
void DMDialog::showResult( TwitterAPI::ErrorCode error )
{
    progress->stop();
    m_ui->progressLabel->hide();
    if ( error == TwitterAPI::NoError ) {
        m_ui->sendingLabel->setText( tr( "Message sent!" ) );
        QTimer::singleShot( 2000, this, SLOT(resetDisplay()) );
    } else {
        m_ui->sendingLabel->setText( tr( "Message sending failed. Note that you cannot send a message "
                                         "to a user that doesn't follow you." ) );
    }
}
Esempio n. 9
0
void displayInit(rxConfig_t *rxConfigToUse)
{
    delay(200);
    resetDisplay();
    delay(200);

    rxConfig = rxConfigToUse;

    memset(&pageState, 0, sizeof(pageState));
    displaySetPage(PAGE_WELCOME);

    updateDisplay();

    displaySetNextPageChangeAt(micros() + (1000 * 1000 * 5));
}
void dashboard_layer_update_data(DashboardLayer *dashboard_layer, DashboardData *dashboard_data){
	if(dashboard_data){
		memcpy(&(dashboard_layer->dashboard_data), dashboard_data, sizeof(DashboardData));
	
		snprintf(dashboard_layer->text_name, sizeof(dashboard_layer->text_name), "%s", dashboard_data->name);
	
		if(dashboard_data->type == NAMain || dashboard_data->type == NAModule4){
			snprintf(dashboard_layer->text_main, sizeof(dashboard_layer->text_main), 
				"%s%d.%d°", 
				dashboard_data->temperature/10 == 0 && dashboard_data->temperature < 0 ? "-" : "",
				dashboard_data->temperature/10, 
				abs(dashboard_data->temperature)%10);
			snprintf(dashboard_layer->text_subtitle, sizeof(dashboard_layer->text_subtitle), "%d%%  %dppm", dashboard_data->humidity, dashboard_data->co2);
			dashboard_layer->dashboard_data.displayed_measure = Temperature;
		}
		else if(dashboard_data->type == NAModule1){
			snprintf(dashboard_layer->text_main, sizeof(dashboard_layer->text_main), 
				"%s%d.%d°", 
				dashboard_data->temperature/10 == 0 && dashboard_data->temperature < 0 ? "-" : "",
				dashboard_data->temperature/10, 
				abs(dashboard_data->temperature)%10);
			snprintf(dashboard_layer->text_subtitle, sizeof(dashboard_layer->text_subtitle), "%d%% %d.%dmb", dashboard_data->humidity, dashboard_data->pressure/10, dashboard_data->pressure%10);
			dashboard_layer->dashboard_data.displayed_measure = Temperature;
		}
		else if(dashboard_data->type == NAModule3){
			snprintf(dashboard_layer->text_main, sizeof(dashboard_layer->text_main), "%d.%03d", dashboard_data->rain/1000, dashboard_data->rain%1000);
			snprintf(dashboard_layer->text_subtitle, sizeof(dashboard_layer->text_subtitle), "Rain (mm)");
			dashboard_layer->dashboard_data.displayed_measure = Rain;
		}
		else if(dashboard_data->type == NAModule2){
			snprintf(dashboard_layer->text_main, sizeof(dashboard_layer->text_main), "%d", dashboard_data->wind_strength);
			snprintf(dashboard_layer->text_subtitle, sizeof(dashboard_layer->text_subtitle), "Gust : %d km/h", dashboard_data->gust_strength);
			dashboard_layer->dashboard_data.displayed_measure = WindStrength;
		}
		else {
		  snprintf(dashboard_layer->text_main, sizeof(dashboard_layer->text_main), " ");
		  snprintf(dashboard_layer->text_subtitle, sizeof(dashboard_layer->text_subtitle), " ");
		  dashboard_layer->dashboard_data.displayed_measure = Temperature;
		}
	
		dashboard_layer_animate_graph(dashboard_layer);
	}
	else {
		resetDisplay(dashboard_layer);
	}

	layer_mark_dirty(dashboard_layer->s_background);
}
Esempio n. 11
0
void dashboardInit(void)
{
    delay(200);
    resetDisplay();
    delay(200);

    displayPort = displayPortOledInit();
#if defined(CMS)
    cmsDisplayPortRegister(displayPort);
#endif

    dashboardSetPage(PAGE_WELCOME);
    const timeUs_t now = micros();
    dashboardSetNextPageChangeAt(now + 5 * MICROSECONDS_IN_A_SECOND);

    dashboardUpdate(now);
}
void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(a0, OUTPUT);
  pinMode(a1, OUTPUT);
  pinMode(a2, OUTPUT);
  pinMode(a3, OUTPUT);
  pinMode(rst, OUTPUT);
  pinMode(ce, OUTPUT);
  pinMode(wr, OUTPUT);
  digitalWrite(ce, HIGH);
  digitalWrite(wr, HIGH);
  
  resetDisplay();
}
Esempio n. 13
0
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
  _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
  Wire.begin();
  delay(200);
  
  resetDisplay();
  if (lines > 1) {
    _displayfunction |= LCD_2LINE;
  }

  // for some 1 line displays you can select a 10 pixel high font
  if ((dotsize != 0) && (lines == 1)) {
    _displayfunction |= LCD_5x10DOTS;
  }

  // finally, set # lines, font size, etc.
  command(LCD_FUNCTIONSET | _displayfunction);  

  // turn the display on with no cursor or blinking default
  _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  
  display();

  // clear it off
  clear();
  home();

  // Initialize to default text direction (for romance languages)
  _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
  // set the entry mode
  command(LCD_ENTRYMODESET | _displaymode);
  delay(50); // OLED needs some more time to initialize
  
  _firmware_version = getFirmwareVersion();
  
  if(_firmware_version >= 2)
  {
	  Wire.beginTransmission(_addr);
	  Wire.write(0xfd); // Set cols/lines
	  Wire.write(cols);
	  Wire.write(lines);
	  Wire.endTransmission();
  }
  
  delay(50);
}
void SSD1306::init(bool reset) {
  Wire.begin();

  if ((reset) && (myRst >= 0)) {
    // Setup reset pin direction (used by both SPI and I2C)
    pinMode(myRst, OUTPUT);
    digitalWrite(myRst, HIGH);
    // VDD (3.3V) goes high at start, lets just chill for a ms
    delay(1);
    // bring reset low
    digitalWrite(myRst, LOW);
    // wait 10ms
    delay(10);
    // bring out of reset
    digitalWrite(myRst, HIGH);
    // turn on VCC (9V?)
  }

  sendInitCommands();
  resetDisplay();
}
Esempio n. 15
0
Synapse::Synapse(int preSynID, int postSynID, bool ExcInh, int ID, float weight, int delayTime, vector<Neuron> *net, ofxXmlSettings* settings){
    this->ExcInh = ExcInh;
    this->preSynID = preSynID;
    this->postSynID = postSynID;
    this->ID = ID;
    this->net = net;
    this->settings = settings;
    this->delayTime = delayTime;
    this->weight = weight;
    
    if (ExcInh){
        weight = 7.0;
        delayTime = round((1 + (randomMax(D-1))) * samplespms);
    }
    else{
        delayTime = round((1 + (randomMax(D-1))) * samplespms);
        weight = -5.0;
    }
    
    reset();    // Init synapse
    resetDisplay();
}
Esempio n. 16
0
/**
 * Initializes a new display screen for the game to render contents to.
 * The screen is set up based on the current options.
 */
Screen::Screen() : _baseWidth(ORIGINAL_WIDTH), _baseHeight(ORIGINAL_HEIGHT), _scaleX(1.0), _scaleY(1.0), _flags(0), _numColors(0), _firstColor(0), _pushPalette(false), _surface(0)
{
	resetDisplay();	
	memset(deferredPalette, 0, 256*sizeof(SDL_Color));
}
Esempio n. 17
0
void SSD1306::init() {
  Wire.begin();
  Wire.setClock(250000);
  sendInitCommands();
  resetDisplay();
}
Esempio n. 18
0
void updateDisplay(void)
{
    uint32_t now = micros();
    static uint8_t previousArmedState = 0;

    bool updateNow = (int32_t)(now - nextDisplayUpdateAt) >= 0L;
    if (!updateNow) {
        return;
    }

    nextDisplayUpdateAt = now + DISPLAY_UPDATE_FREQUENCY;

    bool armedState = ARMING_FLAG(ARMED) ? true : false;
    bool armedStateChanged = armedState != previousArmedState;
    previousArmedState = armedState;

    if (armedState) {
        if (!armedStateChanged) {
            return;
        }
        pageState.pageIdBeforeArming = pageState.pageId;
        pageState.pageId = PAGE_ARMED;
        pageState.pageChanging = true;
    } else {
        if (armedStateChanged) {
            pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
            pageState.pageId = pageState.pageIdBeforeArming;
        }

        pageState.pageChanging = (pageState.pageFlags & PAGE_STATE_FLAG_FORCE_PAGE_CHANGE) ||
                (((int32_t)(now - pageState.nextPageAt) >= 0L && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED)));
        if (pageState.pageChanging && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED)) {
            pageState.cycleIndex++;
            pageState.cycleIndex = pageState.cycleIndex % CYCLE_PAGE_ID_COUNT;
            pageState.pageId = cyclePageIds[pageState.cycleIndex];
        }
    }

    if (pageState.pageChanging) {
        pageState.pageFlags &= ~PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
        pageState.nextPageAt = now + PAGE_CYCLE_FREQUENCY;

        // Some OLED displays do not respond on the first initialisation so refresh the display
        // when the page changes in the hopes the hardware responds.  This also allows the
        // user to power off/on the display or connect it while powered.
        resetDisplay();

        if (!displayPresent) {
            return;
        }
        handlePageChange();
    }

    if (!displayPresent) {
        return;
    }

    switch(pageState.pageId) {
        case PAGE_WELCOME:
            showWelcomePage();
            break;
        case PAGE_ARMED:
            showArmedPage();
            break;
        case PAGE_BATTERY:
            showBatteryPage();
            break;
        case PAGE_SENSORS:
            showSensorsPage();
            break;
        case PAGE_RX:
            showRxPage();
            break;
        case PAGE_PROFILE:
            showProfilePage();
            break;
#ifdef GPS
        case PAGE_GPS:
            if (feature(FEATURE_GPS)) {
                showGpsPage();
            } else {
                pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
            }
            break;
#endif
#ifdef ENABLE_DEBUG_OLED_PAGE
        case PAGE_DEBUG:
            showDebugPage();
            break;
#endif
    }
    if (!armedState) {
        updateFailsafeStatus();
        updateRxStatus();
        updateTicker();
    }

}
Esempio n. 19
0
void dashboardUpdate(timeUs_t currentTimeUs)
{
    static uint8_t previousArmedState = 0;

#ifdef CMS
    if (displayIsGrabbed(displayPort)) {
        return;
    }
#endif

    const bool updateNow = (int32_t)(currentTimeUs - nextDisplayUpdateAt) >= 0L;
    if (!updateNow) {
        return;
    }

    nextDisplayUpdateAt = currentTimeUs + DISPLAY_UPDATE_FREQUENCY;

    bool armedState = ARMING_FLAG(ARMED) ? true : false;
    bool armedStateChanged = armedState != previousArmedState;
    previousArmedState = armedState;

    if (armedState) {
        if (!armedStateChanged) {
            return;
        }
        dashboardSetPage(PAGE_ARMED);
        pageState.pageChanging = true;
    } else {
        if (armedStateChanged) {
            pageState.pageFlags |= PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
        }

        pageState.pageChanging = (pageState.pageFlags & PAGE_STATE_FLAG_FORCE_PAGE_CHANGE) ||
                (((int32_t)(currentTimeUs - pageState.nextPageAt) >= 0L && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED)));
        if (pageState.pageChanging && (pageState.pageFlags & PAGE_STATE_FLAG_CYCLE_ENABLED)) {

            do {
                pageState.cycleIndex++;
                pageState.cycleIndex = pageState.cycleIndex % PAGE_COUNT;
                pageState.page = &pages[pageState.cycleIndex];
            } while (pageState.page->flags & PAGE_FLAGS_SKIP_CYCLING);
        }
    }

    if (pageState.pageChanging) {
        pageState.pageFlags &= ~PAGE_STATE_FLAG_FORCE_PAGE_CHANGE;
        pageState.nextPageAt = currentTimeUs + PAGE_CYCLE_FREQUENCY;

        // Some OLED displays do not respond on the first initialisation so refresh the display
        // when the page changes in the hopes the hardware responds.  This also allows the
        // user to power off/on the display or connect it while powered.
        resetDisplay();

        if (!dashboardPresent) {
            return;
        }
        handlePageChange();
    }

    if (!dashboardPresent) {
        return;
    }

    pageState.page->drawFn();

    if (!armedState) {
        updateFailsafeStatus();
        updateRxStatus();
        updateTicker();
    }

}
Esempio n. 20
0
void dashboardUpdate(timeUs_t currentTimeUs)
{
    static uint8_t previousArmedState = 0;
    bool pageChanging;

#ifdef CMS
    static bool wasGrabbed = false;
    if (displayIsGrabbed(displayPort)) {
        wasGrabbed = true;
        return;
    } else if (wasGrabbed) {
        pageChanging = true;
        wasGrabbed = false;
    } else {
        pageChanging = false;
    }
#else
    pageChanging = false;
#endif

    bool updateNow = (int32_t)(currentTimeUs - nextDisplayUpdateAt) >= 0L;

    if (!updateNow) {
        return;
    }

    nextDisplayUpdateAt = currentTimeUs + DASHBOARD_UPDATE_FREQUENCY;

    bool armedState = ARMING_FLAG(ARMED) ? true : false;
    bool armedStateChanged = armedState != previousArmedState;
    previousArmedState = armedState;

    if (armedState) {
        if (!armedStateChanged) {
            return;
        }
        currentPageId = PAGE_ARMED;
        pageChanging = true;
    } else {
        if (armedStateChanged) {
            currentPageId = PAGE_STATUS;
            pageChanging = true;
        }

        if ((currentPageId == PAGE_WELCOME) && ((int32_t)(currentTimeUs - nextPageAt) >= 0L)) {
            currentPageId = PAGE_STATUS;
            pageChanging = true;
        }

        if (forcePageChange) {
            pageChanging = true;
            forcePageChange = false;
        }
    }

    if (pageChanging) {
        // Some OLED displays do not respond on the first initialisation so refresh the display
        // when the page changes in the hopes the hardware responds.  This also allows the
        // user to power off/on the display or connect it while powered.
        if (!displayPresent) {
            resetDisplay();
        }

        if (!displayPresent) {
            return;
        }

        i2c_OLED_clear_display_quick();
        showTitle();
    }

    if (!displayPresent) {
        return;
    }

    switch(currentPageId) {
        case PAGE_WELCOME:
            showWelcomePage();
            break;
        case PAGE_ARMED:
            showArmedPage();
            break;
        case PAGE_STATUS:
            showStatusPage();
            break;
    }

    if (!armedState) {
        updateFailsafeStatus();
        updateRxStatus();
        updateTicker();
    }
}
Esempio n. 21
0
void Synapse::setPostSynID(int ID){
    postSynID = ID;
    resetDisplay();
}
Esempio n. 22
0
void Synapse::setPreSynID(int ID){
    preSynID = ID;
    resetDisplay();
}
/**
 * Routine for clearing out ALL displays.
 */
void mizraith_HDSP2111::resetDisplays() {
  for(uint8_t displaynum=1; displaynum <= NUMBER_OF_DISPLAYS; displaynum++) {
      resetDisplay(displaynum);
  }
}