Esempio n. 1
0
/*!
    This function activates the appropriate actions for the given
    power management \a level.
*/
bool PhonePowerManager::save(int level)
{
    QSettings config("Trolltech", "qpe");
    config.beginGroup("HomeScreen");
    QString showHomeScreen = config.value("ShowHomeScreen", "Never").toString();    //Note: defaults need to be in sync with
    bool autoKeyLock = config.value("AutoKeyLock", false).toBool();                //defaults in homescreen settings app
    int action = m_levelToAction.value(level);
    qLog(PowerManagement) << "PhonePowerManager::save()" << "level" << level << "action" << action << "homescreen settings:" << showHomeScreen << autoKeyLock;

    switch (action) {
        case PhonePowerManager::DimLight:
            if ( m_powerConstraint > QtopiaApplication::Disable && m_dimLightEnabled ) {
                m_vso->setAttribute("ScreenSaver/CurrentLevel", 1 );
                if (backlight() > 1)
                    setBacklight(1); // lowest non-off
                qLog(PowerManagement) << "Dimming light";
                return true;
            }
            break;
        case PhonePowerManager::LightOff:
            if ( m_powerConstraint > QtopiaApplication::DisableLightOff
                    && m_lightOffEnabled ) {
                m_vso->setAttribute("ScreenSaver/CurrentLevel", 2 );
                setBacklight(0); // off

                if (showHomeScreen == "DisplayOff") {
                    qLog(PowerManagement) << "Showing HomeScreen";
                    QtopiaIpcEnvelope showHome("QPE/System", autoKeyLock ?
                                               "showHomeScreenAndKeylock()" : "showHomeScreen()");
                }

                qLog(PowerManagement) << "turning light off";
                return true;
            }
            break;
        case PhonePowerManager::Suspend:
            qLog(PowerManagement) << "case PhonePowerManager::Suspend:" << "m_powerConstraint" << m_powerConstraint << "m_suspendEnabled" << m_suspendEnabled;
            if (m_powerConstraint > QtopiaApplication::DisableSuspend
                    && m_suspendEnabled) {
                m_vso->setAttribute("ScreenSaver/CurrentLevel", 3 );

                if (showHomeScreen == "Suspend") {
                    qLog(PowerManagement) << "Showing HomeScreen";
                    QtopiaIpcEnvelope showHome("QPE/System", autoKeyLock ?
                                               "showHomeScreenAndKeylock()" : "showHomeScreen()");
                }
                qLog(PowerManagement) << "Suspending device";
                SystemSuspend *suspend = qtopiaTask<SystemSuspend>();
                suspend->suspendSystem();
                return true;
            }
            break;
        default:
            ;
    }
    return false;
}
Esempio n. 2
0
int myLCDSwap()
{
	lcdSwap();
	if (GUI.hide)
	{
		if (REG_POWERCNT & POWER_SWAP_LCDS)
			setBacklight(PM_BACKLIGHT_TOP);
		else
			setBacklight(PM_BACKLIGHT_BOTTOM);
	}
	return 0;
}
Esempio n. 3
0
void LCD_5110_SPI::begin() {
    pinMode(_pinChipSelect, OUTPUT);
    pinMode(_pinReset, OUTPUT);
    pinMode(_pinDataCommand, OUTPUT);
    //  pinMode(_pinSerialData, OUTPUT);
    //  pinMode(_pinSerialClock, OUTPUT);
    pinMode(_pinBacklight, OUTPUT);
    pinMode(_pinPushButton, INPUT_PULLUP);
    
    
    
    digitalWrite(_pinDataCommand, LOW);
    delay(30);
    digitalWrite(_pinReset, LOW);
    delay(100); // as per 8.1 Initialisation
    digitalWrite(_pinReset, HIGH);
    
    write(_commandLCD, 0x21); // chip is active, horizontal addressing, use extended instruction set
    write(_commandLCD, 0xc8); // write VOP to register: 0xC8 for 3V — try other values
    write(_commandLCD, 0x12); // set Bias System 1:48
    write(_commandLCD, 0x20); // chip is active, horizontal addressing, use basic instruction set
    write(_commandLCD, 0x09); // temperature control
    write(_commandLCD, 0x0c); // normal mode
    delay(10);
    
    clear();
    _font = 0;
    setBacklight(false);
}
Esempio n. 4
0
// Interface
// 2.1 General Commands
// AutoBaud - 55hex 
void Serial_LCD::begin(int8_t resetPin0) {
  // default speed = 9600
    
  // reset is required for Goldelox-based screens
  if (resetPin0 > -1) {
      delay(3000);
      pinMode(resetPin0, OUTPUT);
      digitalWrite(resetPin0, LOW);
      delay(10);
      digitalWrite(resetPin0, HIGH);
      delay(10);
  }

  // LCD 500 ms power-up
  // SD card 3000 ms power-up
  delay(500);
  _port->print('U');    // connect
  while (_port->read()!=0x06)  {     
    delay(100);  
  }

  _port->print('o');    // clear touch 
  _port->print((char)0x04);   // touch state
  //  _port->flush();
  delay(100);
  while (_port->available()) _port->read();

  setBacklight(true);  // backlight on
  setDisplay(true);  // display on
  setOrientation(3);
  clear();
  setFont(1);
  _checkedSD=false;  // SD not checked

}
Esempio n. 5
0
void LcdI2c::init(void){

    //switch to 4 bit mode 
    send4(0x03,LCD_CMD);
    delay(100000);
    send4(0x03,LCD_CMD);
    delay(100000);
    send4(0x03,LCD_CMD);
    delay(100000);
    send4(0x02,LCD_CMD);
    delay(100000);
    //done

    //setup driver
    cmd8(LCD_FUNCTIONSET |  LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS);
    delay(100000);
    cmd8(LCD_CURSORSHIFT | LCD_MOVERIGHT | LCD_CURSORMOVE );
    delay(100000);
    cmd8(LCD_DISPLAYCONTROL | LCD_DISPLAYON  | LCD_CURSOROFF | LCD_BLINKOFF );
    delay(100000);
    cmd8(LCD_RETURNHOME ) ;   
    delay(100000);
    cmd8(LCD_CLEARDISPLAY);
    delay(100000);

    setBacklight(0);


}
Esempio n. 6
0
LCD::~LCD() {
    setBacklight(0);
    setText("",0);
    setText("",1);
    CPhidget_close((CPhidgetHandle)txt_lcd);
    CPhidget_delete((CPhidgetHandle)txt_lcd);
}
void ControLeo_LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
    // Start I2C
    _i2c.begin();
    
    // Turn on the backlight
    setBacklight(HIGH);

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

    // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
    // According to datasheet, we need at least 40ms after power rises above 2.7V
    // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
    delayMicroseconds(50000);
    
    // Now we pull both RS and R/W low to begin commands
    _i2c.digitalWrite(_rs_pin, LOW);
    _i2c.digitalWrite(_enable_pin, LOW);
    
    //Put the LCD into 4 bit mode
    // This is according to the hitachi HD44780 datasheet figure 24, pg 46
    // We start in 8bit mode, try to set 4 bit mode
    write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms
    
    // Second try
    write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms
    
    // Third go!
    write4bits(0x03);
    delayMicroseconds(150);
    
    // Finally, set to 8-bit interface
    write4bits(0x02);
    
    // 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 the display
    clear();
    
    // Initialize to default text direction (for romance languages)
    _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
    // Set the entry mode
    command(LCD_ENTRYMODESET | _displaymode);
}
Esempio n. 8
0
LCDManager::LCDManager()
{
  lcd = new LiquidCrystalFast(
      LCD_RS_PIN, LCD_RW_PIN, LCD_EN_PIN,
      LCD_D4_PIN, LCD_D5_PIN, LCD_D6_PIN, LCD_D7_PIN
    );
  lcd->begin(LCD_COLS, LCD_ROWS);

  pinMode(LCD_BL_PIN, OUTPUT);
  setBacklight(0);

  showVersionSplash();
}
Esempio n. 9
0
void Screen_HX8353E::begin()
{
#if defined(__LM4F120H5QR__)
    SPI.setModule(2);
#endif
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV2);
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE0);
    if (_pinReset!=NULL) pinMode(_pinReset, OUTPUT);
    if (_pinBacklight!=NULL) pinMode(_pinBacklight, OUTPUT);
    pinMode(_pinDataCommand, OUTPUT);
    pinMode(_pinChipSelect, OUTPUT);
    if (_pinBacklight!=NULL) digitalWrite(_pinBacklight, HIGH);
    if (_pinReset!=NULL) digitalWrite(_pinReset, 1);
    delay(100);
    if (_pinReset!=NULL) digitalWrite(_pinReset, 0);
    delay(50);
    if (_pinReset!=NULL) digitalWrite(_pinReset, 1);
    delay(120);
    _writeCommand(HX8353E_SWRESET);
    delay(150);
    _writeCommand(HX8353E_SLPOUT);
    delay(200);
    _writeRegister(HX8353E_GAMSET, 0x04);
    _writeCommand(HX8353E_SETPWCTR);
    _writeData88(0x0A, 0x14);
    _writeCommand(HX8353E_SETSTBA);
    _writeData88(0x0A, 0x00);
    _writeRegister(HX8353E_COLMOD, 0x05);
    delay(10);
    _writeRegister(HX8353E_MADCTL, HX8353E_MADCTL_RGB);
    _writeCommand(HX8353E_CASET);
    _writeData8888(0x00, 0x00, 0x00, 0x79);
    _writeCommand(HX8353E_RASET);
    _writeData8888(0x00, 0x00, 0x00, 0x79);
    _writeCommand(HX8353E_NORON);
    delay(10);
    _writeCommand(HX8353E_DISPON);
    delay(120);
    _writeCommand(HX8353E_RAMWR);
    setBacklight(true);
    setOrientation(0);
    _screenWidth  = HX8353E_WIDTH;
    _screenHeigth = HX8353E_HEIGHT;
    _penSolid  = false;
    _fontSolid = true;
    _flagRead  = false;
    _touchTrim = 0;
    clear();
}
Esempio n. 10
0
void LCD5110::LCD_putchar(char c) {
	if (prev_char == 27) {
		switch (c) {
		case '0':
			clear();
			break;
		case '1':
			setPosition(0, 0);
			break;
		case '2':
			highlighted = false;
			break;
		case '3':
			highlighted = true;
			break;
		case '4':
			setBacklight(ON);
			break;
		case '5':
			setBacklight(OFF);
			break;
		}
	} else {
		switch (c) {
		case '\r':
			for (char n = x; n < NUM_COL; n++) {
				drawChar(' ', highlighted);
			}
			break;
		case '\n':
			break;
		default:
			drawChar(c, highlighted);
		}
	}
	prev_char = c;
}
Esempio n. 11
0
void Serial_LCD::off() {
  clear();

  _port->print('o');
  _port->print((char)0x04);   // state
  _port->flush();

  setBacklight(false);  // backlight off
  clear();
  setDisplay(false);  // display off

  _port->print('Q');    // reset to default speed
  _port->print((char)0x06);    // 
  delay(10);
}
Esempio n. 12
0
int main(int argc, char *argv[]) {
    if (argc != 2 ) {
        printf("Usage:\nlcdbacklight brightness\n");
        return 1;
    } else {
        int bckl=atoi(argv[1]);
        if (bckl<0 || bckl> 255) {
            printf("backlight must be between 0 and 255\n");
            return 2;
        }
        lcd=serialOpen(SERIAL, BAUD_RATE);
        setBacklight(atoi(argv[1]));
        serialClose(lcd);
        return 0;
    }
}
Esempio n. 13
0
void screenBegin() {
    // Screen_HX8353E::begin()

    /*
     * this is a 8MHz speed (16MHz Arduino speed/2)
     * In HalCoGen, on data format 0, I defined Baudrate 8000 kHz
     */
    mibspiInit();

    gioSetBit(_portReset, _pinReset, 1);
    delay(100);
    gioSetBit(_portReset, _pinReset, 0);
    delay(50);
    gioSetBit(_portReset, _pinReset, 1);
    delay(120);
    _writeCommand(HX8353E_SWRESET);
    delay(150);
    _writeCommand(HX8353E_SLPOUT);
    delay(200);
    _writeRegister(HX8353E_GAMSET, 0x04);
    _writeCommand(HX8353E_SETPWCTR);
    _writeData88(0x0A, 0x14);
    _writeCommand(HX8353E_SETSTBA);
    _writeData88(0x0A, 0x00);
    _writeRegister(HX8353E_COLMOD, 0x05);
    delay(10);
    _writeRegister(HX8353E_MADCTL, HX8353E_MADCTL_RGB);
    _writeCommand(HX8353E_CASET);
    _writeData8888(0x00, 0x00, 0x00, 0x79);
    _writeCommand(HX8353E_RASET);
    _writeData8888(0x00, 0x00, 0x00, 0x79);
    _writeCommand(HX8353E_NORON);
    delay(10);
    _writeCommand(HX8353E_DISPON);
    delay(120);
    _writeCommand(HX8353E_RAMWR);
    setBacklight(true);
    setOrientation(0);
    _screenWidth  = HX8353E_WIDTH;
    _screenHeigth = HX8353E_HEIGHT;
    _penSolid  = false;
    _fontSolid = true;
    _flagRead  = false;
    clear(blackColour);
}
Esempio n. 14
0
void uart0_irq(void) {
	char st = U0IIR & 0x0f;

	// IRQ only valid when IIR_bit_0 == 0
	if (st & 1)
		return;

	switch (st) {
	case IIR_RLS: // Receive Line Status
		putHexW(U0LSR);
		serial_puts(" RLS?!\n");
		
		break;
	case IIR_RDA: // Receive Data Available
	case IIR_CTI: // Character Time-out indication
		if(uart0_incbuffer) {
			while(U0LSR & (1 << 0)) {
				cBufferAdd(uart0_incbuffer,U0RBR);
			}
		}
		else {
			setBacklight(BL_AUTO);
			serial_interactive();
		}
		break;
	case IIR_THRE:
		if(uart0_outcbuffer) {
			if(uart0_outcbuffer->len) {
				unsigned char x = 14;
				while(x-- && uart0_outcbuffer->len) {
					U0THR = cBufferGet(uart0_outcbuffer);
				}
			}
			else {
				U0IER &= ~IER_THRE;
			}
		}
		else {
			serial_puts("THRE?!\n");
		}
		
	}

}
Esempio n. 15
0
/*!
  Constructs a QtopiaPowerManager instance.
  */
QtopiaPowerManager::QtopiaPowerManager() : m_powerConstraint(QtopiaApplication::Enable), m_dimLightEnabled(true), m_lightOffEnabled(true) {
    g_qtopiaPowerManager = this;
    if (!m_vso)
        m_vso = new QValueSpaceObject("/Hardware");
    setBacklight(-3); //forced on

    // Create the screen saver and the associated service.
#ifdef Q_WS_QWS
    QWSServer::setScreenSaver(this);
#endif
    (void)new QtopiaPowerManagerService( this, this );

    QtopiaPowerConstraintManager *tsmMonitor = new QtopiaPowerConstraintManager(this);
    connect( tsmMonitor, SIGNAL(forceSuspend()), this, SLOT(_forceSuspend()) );

    QObject::connect(&powerstatus, SIGNAL(wallStatusChanged(QPowerStatus::WallStatus)), this, SLOT(powerStatusChanged()));
    QObject::connect(&powerstatus, SIGNAL(batteryStatusChanged(QPowerStatus::BatteryStatus)), this, SLOT(powerStatusChanged()));
    QObject::connect(&powerstatus, SIGNAL(batteryChargingChanged(bool)), this, SLOT(powerStatusChanged()));
}
Esempio n. 16
0
void DealDataStreams(BYTE *buf, UINT16 len)
{
	UINT16 i=0;
	DBGD((TEXT("\r\nEXE-System Socket Read %d bytes:"),len));
	for (i=0; i<len; i++)
		DBGD((TEXT("%02X "),buf[i]));

	UINT32 temp=0;
	struct system_t *pSystemInfo = &gSystemInfo;

	switch (buf[0])
	{
	case 0x10:
		if (buf[1] < 11)
			setBacklight(buf[1]);
		break;

	default:
		break;
	}
}
Esempio n. 17
0
void LCD_7110::begin() {
    static const unsigned char init[] = {
        0xa6, // Display: Normal
        0xa3, // LCD Bias Settings: 1/7 0xa3
        0xa1, // ADC Selection: Reverse
        0xc0, // Common Output: Normal Direction
        // 0xC8, // Common Output: Upside Down
        0x22, // Set the V5 output Voltage
        0x81, // Set Electronic Volume Register
        0x2e, // Power Controller Set
        // Booster circuit: ON
        // Voltage regulator circuit: ON
        // Voltage follower circuit: OFF
        0x2f, // Power Controller Set
        // Voltage follower circuit: ON
        0xe3, // Non-OPeration Command
        0x40, // Set the start line
        0xaf, // LCD On
        // 0xA5, // Display All Points: ON
        0xa4, //Display All Points: NORMAL
    };
    
    pinMode(_pinChipSelect, OUTPUT);
    pinMode(_pinReset, OUTPUT);
    pinMode(_pinDataCommand, OUTPUT);
    pinMode(_pinSerialData, OUTPUT);
    pinMode(_pinSerialClock, OUTPUT);
    digitalWrite(_pinReset, LOW);
    delay(1);
    digitalWrite(_pinReset, HIGH);
    for (uint8_t i=0; i<sizeof(init); i++)  write(_commandLCD, init[i]);
    
    pinMode(_pinBacklight, OUTPUT);
    pinMode(_pinPushButton, INPUT_PULLUP);
    
    clear();
    _font = 0;
    setBacklight(false);
}
Esempio n. 18
0
void LiquidTWI::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
	Wire.begin();
	// first thing we do is get the GPIO expander's head working straight, with a boatload of junk data.
	Wire.beginTransmission(MCP23008_ADDRESS | _i2cAddr);
	Wire.send(MCP23008_IODIR);
	Wire.send(0xFF);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);	
	Wire.endTransmission();

	// now we set the GPIO expander's I/O direction to output since it's soldered to an LCD output.
	Wire.beginTransmission(MCP23008_ADDRESS | _i2cAddr);
	Wire.send(MCP23008_IODIR);
	Wire.send(0x00); // all output: 00000000 for pins 1...8
	Wire.endTransmission();

	if (lines > 1) {
		_displayfunction |= LCD_2LINE;
	}
	_numlines = lines;
	_currline = 0;

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

	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
	// according to datasheet, we need at least 40ms after power rises above 2.7V
	// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
	delay(50);

	//put the LCD into 4 bit mode
	// start with a non-standard command to make it realize we're speaking 4-bit here
	// per LCD datasheet, first command is a single 4-bit burst, 0011.
	burstBits(B10010100); // buffer that out to I/O pins: 1001110x with enable and backlight on
	burstBits(B10010000); // buffer that out to I/O pins: 1001100x with enable low, backlight on
	delay(5); // this shouldn't be necessary, but sometimes 16MHz is stupid-fast.
	
	command(LCD_FUNCTIONSET | _displayfunction); // then send 0010NF00 (N=lines, F=font)
	delay(5); // for safe keeping...
	command(LCD_FUNCTIONSET | _displayfunction); // ... twice.
	delay(5); // done!

	// turn on the LCD with our defaults. since these libs seem to use personal preference, I like a cursor.
	_displaycontrol = LCD_DISPLAYON;  
	display();
	// clear it off
	clear();

	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
	// set the entry mode
	command(LCD_ENTRYMODESET | _displaymode);

	setBacklight(HIGH); // turn the backlight on if so equipped.
}
Esempio n. 19
0
bool SysAsus::featureWrite(const QString &id, const QString &nVal)
{
	if (id == LAPSUS_FEAT_BACKLIGHT_ID)
	{
		bool res = false;
		uint uVal = nVal.toUInt(&res);

		if (!res) return false;
		
		return setBacklight(uVal);
	}
	else if (id == LAPSUS_FEAT_LIGHT_SENSOR_LEVEL_ID)
	{
		bool res = false;
		uint uVal = nVal.toUInt(&res);

		if (!res) return false;
		
		return setLightSensorLevel(uVal);
	}
	else if (hasFeature(id))
	{
		uint uVal = 0;

		if (nVal == LAPSUS_FEAT_ON) uVal = 1;
		else if (nVal == LAPSUS_FEAT_OFF) uVal = 0;
		else return false;

		uint oVal = readIdUInt(id);

		if (writeIdUInt(id, uVal))
		{
			/*
			 * We perform write even if it is already set to desired value.
			 * Sometimes old status might not reflect real hardware state.
			 * This way we make sure it is set to correct state.
			 * But we don't want to send info if we don't think it has changed...
			 */
			if (oVal != uVal)
			{
				dbusSignalFeatureUpdate(id, nVal);
				return true;
			}
		}
		
		return false;
	}

	QString disp;

	if (isDisplayFeature(id, disp))
	{
		uint uVal;
		uint offs = 0;

		if (nVal == LAPSUS_FEAT_ON) uVal = 1;
		else if (nVal == LAPSUS_FEAT_ON) uVal = 0;
		else return false;

		if (disp == LAPSUS_FEAT_DISPLAY_LCD) offs = 0;
		else if (disp == LAPSUS_FEAT_DISPLAY_CRT) offs = 1;
		else if (disp == LAPSUS_FEAT_DISPLAY_TV) offs = 2;
		else if (disp == LAPSUS_FEAT_DISPLAY_DVI) offs = 3;
		else return false;

		uint sVal, oVal = readPathUInt(ASUS_DISPLAY_PATH);

		// ON - set the bit
		if (uVal)
		{
			sVal = oVal | (1 << offs);
		}
		// OFF - clear the bit
		else
		{
			sVal = oVal & ~(1 << offs);
		}

		if (sVal != oVal
			&& writePathUInt(ASUS_DISPLAY_PATH, sVal))
		{
			dbusSignalFeatureUpdate(id, nVal);
			return true;
		}

		return false;
	}

	return false;
}
// QT3 DBus message handler:
bool LapsusDaemon::handleMethodCall(const QDBusMessage& message)
{
	if (message.interface() != LAPSUS_INTERFACE) return false;

	if (message.type() != QDBusMessage::MethodCallMessage) return false;

	if (message.member() == "listFeatures"
		|| message.member() == "listSwitches"
		|| message.member() == "listDisplayTypes"
		|| message.member() == "getMaxBacklight"
		|| message.member() == "getBacklight")
	{
		if (message.count() != 0)
		{
			return returnDBusError("org.freedesktop.DBus.Error"
				".InvalidSignature", "Expected no arguments",
				message);
		}

		QDBusMessage reply = QDBusMessage::methodReply(message);

		if (message.member() == "listFeatures")
		{
			reply << QDBusData::fromList(listFeatures());
		}
		else if (message.member() == "listSwitches")
		{
			reply << QDBusData::fromList(listSwitches());
		}
		else if (message.member() == "listDisplayTypes")
		{
			reply << QDBusData::fromList(listDisplayTypes());
		}
		else if (message.member() == "getMaxBacklight")
		{
			reply << QDBusData::fromUInt32(getMaxBacklight());
		}
		else if (message.member() == "getBacklight")
		{
			reply << QDBusData::fromUInt32(getBacklight());
		}
		else
		{
			// Should not happen...
			// TODO - some kind of error? to syslog? using dbus?
			reply << QDBusData::fromUInt32(0);
		}

		myConnection->send(reply);

		return true;
	}
	else if (message.member() == "getSwitch"
		|| message.member() == "getDisplay")
	{
		if (message.count() != 1 || message[0].type() != QDBusData::String)
		{
			return returnDBusError("org.freedesktop.DBus.Error"
				".InvalidSignature",
				"Expected one string argument",
				message);
		}

		QDBusMessage reply = QDBusMessage::methodReply(message);

		if (message.member() == "getSwitch")
		{
			reply << QDBusData::fromBool(
					getSwitch(message[0].toString()));
		}
		else if (message.member() == "getDisplay")
		{
			reply << QDBusData::fromBool(
					getDisplay(message[0].toString()));
		}
		else
		{
			// Should not happen...
			// TODO - some kind of error? to syslog? using dbus?
			reply << QDBusData::fromBool(false);
		}

		myConnection->send(reply);

		return true;
	}
	else if (message.member() == "setSwitch"
		|| message.member() == "setDisplay")
	{
		if (message.count() != 2
			|| message[0].type() != QDBusData::String
			|| message[1].type() != QDBusData::Bool)
		{
			return returnDBusError("org.freedesktop.DBus.Error"
				".InvalidSignature",
				"Expected two arguments: string and bool",
				message);
		}

		QDBusMessage reply = QDBusMessage::methodReply(message);

		if (message.member() == "setSwitch")
		{
			reply << QDBusData::fromBool(
					setSwitch(message[0].toString(),
						message[1].toBool()));
		}
		else if (message.member() == "setDisplay")
		{
			reply << QDBusData::fromBool(
					setDisplay(message[0].toString(),
						message[1].toBool()));
		}
		else
		{
			// Should not happen...
			// TODO - some kind of error? to syslog? using dbus?
			reply << QDBusData::fromBool(false);
		}

		myConnection->send(reply);

		return true;
	}
	else if (message.member() == "setBacklight")
	{
		if (message.count() != 1
			|| message[0].type() != QDBusData::UInt32)
		{
			return returnDBusError("org.freedesktop.DBus.Error"
				".InvalidSignature",
				"Expected one uint32 argument",
				message);
		}

		QDBusMessage reply = QDBusMessage::methodReply(message);

		if (message.member() == "setBacklight")
		{
			reply << QDBusData::fromBool(
					setBacklight(message[0].toUInt32()));
		}
		else
		{
			// Should not happen...
			// TODO - some kind of error? to syslog? using dbus?
			reply << QDBusData::fromBool(false);
		}

		myConnection->send(reply);

		return true;
	}

	// TODO - cpufreq

	return false;
}
Esempio n. 21
0
/*	Return Values:
	0 = OK
	1 = too manny pulse lengths
	2 = abort
	3 = too long
*/
unsigned char captureIR(struct ir_raw_* capture) {
	
	unsigned long hightime, lowtime;
	unsigned long T0count;
	unsigned short highpulse, lowpulse;
	unsigned long T1count;
	unsigned long timeout;
	unsigned char status;
	unsigned char wide;
	
	while(ANYKEY);
	
	setSpeed(SPEED_60);
	disableIRQ();
	T0MCR = 0x00;
	
	FIOSET0 |= (1<<4);
	FIOCLR0 |= (1<<12);
	PINSEL1 |= (1<<27);
		
	T0CCR = (1<<9) | (1<<10) | (1<<11);
		
	capture->widetable[0].count = 0;
	capture->widetable[1].count = 0;
	capture->count = 0;
	status = 0;
	
	T0TC = 0;
	while (T0TC < 5000);
	
	T0IR = 0xff;
	while (!T0IR && !ANYKEY);
	if(!ANYKEY) {
		T0TC = 0;
		T0IR = 0xff;
		T0count = waitIrHi(&highpulse,&hightime,0);
		capture->pulsetime = (hightime * 1000) / highpulse;
		capture->data[0] = (decodewide(highpulse, &capture->widetable[1]) & 0x0F)<<4;
		
		while (!(T0IR));
		T0IR = 0xff;
		T1count= T0CR3;
		while ((capture->count < max_capture_data-1) && !status) {
			lowtime = T1count-T0count;
			T0count = waitIrHi(&highpulse,&hightime,T1count);		
			lowpulse = ((lowtime *1000)+(capture->pulsetime / 2)) / capture->pulsetime;
			wide = decodewide(lowpulse, &capture->widetable[1]);
			if(wide & 0xf0)
				status = 2;
			capture->data[capture->count] |= wide;
			wide = decodewide(highpulse, &capture->widetable[1]);
			if(wide & 0xf0)
				status = 2;
			capture->count++;
			capture->data[capture->count] = wide<<4;
			timeout = T0count + 500000;
			while (!(T0IR) && !status) {
				if (T0TC > timeout)
					status =1;
			}
			T0IR = 0xff;
			T1count= T0CR3;
		}
	}
	else
		status = 3;
	if(capture->count == max_capture_data-1)
		status = 4;
	T0TC = 0;
	T0MCR = 0x03;
	FIOSET0 |= (1<<12);
	T0CCR = 0;
	T0IR = 0xff;
	enableIRQ();
	setBacklight(BL_AUTO);
	setSpeed(SPEED_30);
	return status - 1;
} 
Esempio n. 22
0
/*!
    \fn void QtopiaPowerManager::restore()

    Restores the state of the device when power saving is active. This
    usually happens when the user interacts with the device.
*/
void QtopiaPowerManager::restore()
{
    qLog(PowerManagement) << "QtopiaPowerManager: restoring screen saver";
    if ( backlight() <= 1 ) //if dimmed or off
        setBacklight(-1);
}
Esempio n. 23
0
//
// Switch off the backlight
void LCD::noBacklight ( void )
{
   setBacklight(0);
}
Esempio n. 24
0
//
// Switch on the backlight
void LCD::backlight ( void )
{
   setBacklight(255);
}
void LiquidTWI::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
	// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
	// according to datasheet, we need at least 40ms after power rises above 2.7V
	// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
	delay(50);

	Wire.begin();
	// first thing we do is get the GPIO expander's head working straight, with a boatload of junk data.
	Wire.beginTransmission(MCP23008_ADDRESS | _i2cAddr);
#if ARDUINO >= 100
	Wire.write((byte)MCP23008_IODIR);
	Wire.write((byte)0xFF);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
	Wire.write((byte)0x00);
#else
	Wire.send(MCP23008_IODIR);
	Wire.send(0xFF);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
	Wire.send(0x00);
#endif
	Wire.endTransmission();

	// now we set the GPIO expander's I/O direction to output since it's soldered to an LCD output.
	Wire.beginTransmission(MCP23008_ADDRESS | _i2cAddr);
#if ARDUINO >= 100
	Wire.write((byte)MCP23008_IODIR);
	Wire.write((byte)0x00); // all output: 00000000 for pins 1...8
#else
	Wire.send(MCP23008_IODIR);
	Wire.send(0x00); // all output: 00000000 for pins 1...8
#endif
	Wire.endTransmission();

	if (lines > 1) {
		_displayfunction |= LCD_2LINE;
	}
	_numlines = lines;
	_currline = 0;

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

	//put the LCD into 4 bit mode
	// start with a non-standard command to make it realize we're speaking 4-bit here
	// per LCD datasheet, first command is a single 4-bit burst, 0011.
        //-----
        //  we cannot assume that the LCD panel is powered at the same time as
        //  the arduino, so we have to perform a software reset as per page 45
        //  of the HD44780 datasheet - (kch)
        //-----
        // bit pattern for the burstBits function is
        //
        //  7   6   5   4   3   2   1   0
        // LT  D7  D6  D5  D4  EN  RS  n/c
        //-----
        burstBits(B10011100); // send LITE D4 D5 high with enable
        burstBits(B10011000); // send LITE D4 D5 high with !enable
        burstBits(B10011100); //
        burstBits(B10011000); //
        burstBits(B10011100); // repeat twice more
        burstBits(B10011000); //
        burstBits(B10010100); // send D4 low and LITE D5 high with enable
        burstBits(B10010000); // send D4 low and LITE D5 high with !enable
	delay(5); // this shouldn't be necessary, but sometimes 16MHz is stupid-fast.
	
	command(LCD_FUNCTIONSET | _displayfunction); // then send 0010NF00 (N=lines, F=font)
	delay(5); // for safe keeping...
	command(LCD_FUNCTIONSET | _displayfunction); // ... twice.
	delay(5); // done!

	// turn on the LCD with our defaults. since these libs seem to use personal preference, I like a cursor.
	_displaycontrol = LCD_DISPLAYON;  
	display();
	// clear it off
	clear();

	_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
	// set the entry mode
	command(LCD_ENTRYMODESET | _displaymode);

	setBacklight(HIGH); // turn the backlight on if so equipped.
}
Esempio n. 26
0
/***********************************************************************
		module		:	[菜单操作]
		function	:	[机器设置菜单操作]
  		return		:	[无]
		comment		:	[全局普通函数]
		machine		:	[EH-0818]
		language	:	[CHN]
 		keyword		:	[MENU]
		date		:	[11/07/20]
 		author		:	[chen-zhengkai]
************************************************************************/
void funSet_task()
{
	int select = -1;
	char fun_menu_str[] =	"1. 时间设置      "
							"2. 日期设置      "
							"3. 待机时间设置  "
							"4. 背光灯时间设置"
							"5. 按键音设置    "
							"6. 机器参数查询  "
							"7. 读取授权卡    ";
	BROWINFO	info;
	info.iStr = fun_menu_str;		//浏览内容指针
	info.lPtr = 0;					//显示内容iStr的起始显示行
	info.cPtr = 0;					//当前选择行
	

	
	while (1) {
		//以下BROWINFO结构成员变量必须参与循环,有可能会被EXT_Brow_Select函数改变
		info.startLine = 2;				//在LCD上的显示起始行
		info.dispLines = 7;				//在LCD上的显示行数
		info.mInt = 7;					//显示内容的总行数
		info.lineMax = 17;				//每行最大字符数
		info.sFont = 0;					//7x9大字体显示
		info.numEnable = 0;				//是否允许数字键代替方向控制
		info.qEvent = EXIT_KEY_F1|EXIT_AUTO_QUIT|EXIT_KEY_POWER|EXIT_KEY_CANCEL;    //可导致函数退出的事件标志
		info.autoexit = 1200;			//自动退出的时间
		//菜单
		Disp_Clear();
		DispStr_CE(0, 0, "机器设置菜单", DISP_CENTER);
		select = EXT_Brow_Select(&info);
		switch (select) {
			case 0:		//时间设置
				setTime();
				break;
			case 1:		//日期设置
				setDate();
				break;
			case 2:		//待机时间设置
				Set_Auto_Poweroff();
				break;
			case 3:		//背光灯时间设置
				setBacklight();
				break;
			case 4:		//按键音设置
				setKeybeeper();
				break;
			case 5:		//机器参数查询
				break;
			case 6:		//读取授权卡
				getAuthorize();
				break;
			default:	//降低CPU占用率,降低能耗
				if (info.qEvent == EXIT_KEY_F1  || EXIT_AUTO_QUIT 
                                || EXIT_KEY_POWER || EXIT_KEY_CANCEL) { //返回上级菜单 
					return;
				}
				Sys_Power_Sleep(3);
				break;
		}
	}
}
Esempio n. 27
0
// Does some (perhaps not so) helpful init of the SerLCD.   
void SerLCD::begin()
{
	displayOn(); 
	clear(); 
	setBacklight(157); 
}
Esempio n. 28
0
//
// setBacklightPin
void LiquidCrystal_I2C::setBacklightPin(uint8_t value, t_backlighPol pol = POSITIVE) {
    _backlightPinMask = 1 << value;
    _polarity = pol;
    setBacklight(BACKLIGHT_OFF);
}
Esempio n. 29
0
void Adafruit_RGBLCDShield::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
  // check if i2c
  if (_i2cAddr != 255) {
    //_i2c.begin(_i2cAddr);
    Wire.begin();
    _i2c.begin();

    _i2c.pinMode(8, OUTPUT);
    _i2c.pinMode(6, OUTPUT);
    _i2c.pinMode(7, OUTPUT);
    setBacklight(0x7);

    if (_rw_pin)
      _i2c.pinMode(_rw_pin, OUTPUT);

    _i2c.pinMode(_rs_pin, OUTPUT);
    _i2c.pinMode(_enable_pin, OUTPUT);
    for (uint8_t i=0; i<4; i++) 
      _i2c.pinMode(_data_pins[i], OUTPUT);

    for (uint8_t i=0; i<5; i++) {
      _i2c.pinMode(_button_pins[i], INPUT);
      _i2c.pullUp(_button_pins[i], 1);
    }
  }

  if (lines > 1) {
    _displayfunction |= LCD_2LINE;
  }
  _numlines = lines;
  _currline = 0;

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

  // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
  // according to datasheet, we need at least 40ms after power rises above 2.7V
  // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
  delayMicroseconds(50000); 
  // Now we pull both RS and R/W low to begin commands
  _digitalWrite(_rs_pin, LOW);
  _digitalWrite(_enable_pin, LOW);
  if (_rw_pin != 255) { 
    _digitalWrite(_rw_pin, LOW);
  }
  
  //put the LCD into 4 bit or 8 bit mode
  if (! (_displayfunction & LCD_8BITMODE)) {
    // this is according to the hitachi HD44780 datasheet
    // figure 24, pg 46

    // we start in 8bit mode, try to set 4 bit mode
    write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms

    // second try
    write4bits(0x03);
    delayMicroseconds(4500); // wait min 4.1ms
    
    // third go!
    write4bits(0x03); 
    delayMicroseconds(150);

    // finally, set to 8-bit interface
    write4bits(0x02); 
  } else {
    // this is according to the hitachi HD44780 datasheet
    // page 45 figure 23

    // Send function set command sequence
    command(LCD_FUNCTIONSET | _displayfunction);
    delayMicroseconds(4500);  // wait more than 4.1ms

    // second try
    command(LCD_FUNCTIONSET | _displayfunction);
    delayMicroseconds(150);

    // third go
    command(LCD_FUNCTIONSET | _displayfunction);
  }

  // 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();

  // Initialize to default text direction (for romance languages)
  _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
  // set the entry mode
  command(LCD_ENTRYMODESET | _displaymode);

}
Esempio n. 30
0
void Screen_HX8353E::setDisplay(boolean flag)
{
    if (_pinBacklight!=NULL) setBacklight(flag);
}