Example #1
0
void HttpFileTransfer::transferTerminated(bool bSuccess)
{
	KviWindow * out = transferWindow();

	m_tTransferEndTime = kvi_unixTime();

	KviKvsVariantList vParams;
	vParams.append(bSuccess);
	vParams.append(new KviKvsVariant(m_pHttpRequest->url().url(), true));
	vParams.append(new KviKvsVariant(m_pHttpRequest->fileName(), true));
	vParams.append(new KviKvsVariant(m_vMagicIdentifier));

	if(m_szCompletionCallback.isNull())
	{
		KVS_TRIGGER_EVENT(KviEvent_OnHTTPGetTerminated,out ? out : (KviWindow *)(g_pApp->activeConsole()),&vParams)
	} else {
		KviKvsScript::run(m_szCompletionCallback,out ? out : (KviWindow *)(g_pApp->activeConsole()),&vParams);
	}

	if(bSuccess)
	{
		m_szStatusString = __tr2qs_ctx("Transfer completed","http");
		m_eGeneralStatus = Success;
		displayUpdate();
		if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICSUCCESS,__tr2qs_ctx("[HTTP %d]: Transfer completed","http"),id());
		g_pApp->fileDownloadTerminated(
				true,
				m_pHttpRequest->url().url(),
				m_pHttpRequest->fileName(),
				QString(),
				QString(),
				!m_bNotifyCompletion
			);
	} else {
		m_szStatusString = __tr2qs_ctx("Transfer failed","http");
		m_szStatusString += ": ";
		m_szStatusString += m_pHttpRequest->lastError();
		m_eGeneralStatus = Failure;
		displayUpdate();
		if(out && (!m_bNoOutput))out->output(KVI_OUT_GENERICERROR,__tr2qs_ctx("[HTTP %d]: Transfer failed: %Q","http"),id(),&(m_pHttpRequest->lastError()));
		g_pApp->fileDownloadTerminated(
				false,
				m_pHttpRequest->url().url(),
				m_pHttpRequest->fileName(),
				QString(),
				m_pHttpRequest->lastError(),
				!m_bNotifyCompletion
			);
	}

	if(m_bAutoClean)
	{
		if(m_pAutoCleanTimer)delete m_pAutoCleanTimer;
		m_pAutoCleanTimer = new QTimer();
		connect(m_pAutoCleanTimer,SIGNAL(timeout()),this,SLOT(autoClean()));
		m_pAutoCleanTimer->start(100);
		m_TimerId=m_pAutoCleanTimer->timerId();
	}
}
Example #2
0
void CLCD::showVolume(const char vol, const bool perform_update)
{
	volume = vol;
	if (
	    ((mode == MODE_TVRADIO || mode == MODE_MOVIE) &&
	     g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] != STATUSLINE_PLAYTIME) ||
	    (mode == MODE_SCART) ||
	    (mode == MODE_AUDIO)
	   )
	{
		display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF);
		//strichlin
		if ((muted) || (volume==0))
		{
			display.draw_line (12,55,72,59, CLCDDisplay::PIXEL_ON);
		}
		else
		{
			int dp = vol*61/100+12;
			display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON);
		}
		if(mode == MODE_AUDIO)
		{
			display.draw_fill_rect (-1, 51, 10, 62, CLCDDisplay::PIXEL_OFF);
			display.draw_rectangle ( 1, 55,  3, 58, CLCDDisplay::PIXEL_ON, CLCDDisplay::PIXEL_OFF);
			display.draw_line      ( 3, 55,  6, 52, CLCDDisplay::PIXEL_ON);
			display.draw_line      ( 3, 58,  6, 61, CLCDDisplay::PIXEL_ON);
			display.draw_line      ( 6, 54,  6, 59, CLCDDisplay::PIXEL_ON);
		}

		if (perform_update)
		  displayUpdate();
	}
	wake_up();
}
Example #3
0
// timer 0: OFF, timer>0 time to show in seconds,  timer>=999 endless
void CVFD::showInfoBox(const char * const title, const char * const text ,int autoNewline,int timer)
{
#ifdef HAVE_LCD
	if(!has_lcd) return;
        //printf("[lcdd] Info: \n");
        if(text != NULL)
                m_infoBoxText = text;
        if(text != NULL)
                m_infoBoxTitle = title;
        if(timer != -1)
                m_infoBoxTimer = timer;
        if(autoNewline != -1)
                m_infoBoxAutoNewline = autoNewline;

        //printf("[lcdd] Info: %s,%s,%d,%d\n",m_infoBoxTitle.c_str(),m_infoBoxText.c_str(),m_infoBoxAutoNewline,m_infoBoxTimer);
        if( mode == MODE_INFOBOX &&
            !m_infoBoxText.empty())
        {
                // paint empty box
                display.draw_fill_rect (EPG_INFO_WINDOW_POS, EPG_INFO_WINDOW_POS,       LCD_WIDTH-EPG_INFO_WINDOW_POS+1,          LCD_HEIGTH-EPG_INFO_WINDOW_POS+1,    CLCDDisplay::PIXEL_OFF);
                display.draw_fill_rect (EPG_INFO_LINE_POS,       EPG_INFO_LINE_POS,     LCD_WIDTH-EPG_INFO_LINE_POS-1,    LCD_HEIGTH-EPG_INFO_LINE_POS-1,        CLCDDisplay::PIXEL_ON);
                display.draw_fill_rect (EPG_INFO_BORDER_POS, EPG_INFO_BORDER_POS,       LCD_WIDTH-EPG_INFO_BORDER_POS-3,  LCD_HEIGTH-EPG_INFO_BORDER_POS-3, CLCDDisplay::PIXEL_OFF);

                // paint title
                if(!m_infoBoxTitle.empty())
                {
                        int width = fonts.menu->getRenderWidth(m_infoBoxTitle.c_str(),true);
                        if(width > 100)
                                width = 100;
                        int start_pos = (120-width) /2;
                        display.draw_fill_rect (start_pos, EPG_INFO_WINDOW_POS-4,       start_pos+width+5,        EPG_INFO_WINDOW_POS+10,    CLCDDisplay::PIXEL_OFF);
                        fonts.menu->RenderString(start_pos+4,EPG_INFO_WINDOW_POS+5, width+5, m_infoBoxTitle.c_str(), CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
                }

                // paint info
                std::string text_line;
                int line;
                int pos = 0;
                int length = m_infoBoxText.size();
                for(line = 0; line < 5; line++)
                {
                        text_line.clear();
                        while ( m_infoBoxText[pos] != '\n' &&
                                        ((fonts.menu->getRenderWidth(text_line.c_str(), true) < EPG_INFO_TEXT_WIDTH-10) || !m_infoBoxAutoNewline )&&
                                        (pos < length)) // UTF-8
                        {
                                if ( m_infoBoxText[pos] >= ' ' && m_infoBoxText[pos] <= '~' )  // any char between ASCII(32) and ASCII (126)
                                        text_line += m_infoBoxText[pos];
                                pos++;
                        }
                        //printf("[lcdd] line %d:'%s'\r\n",line,text_line.c_str());
                        fonts.menu->RenderString(EPG_INFO_TEXT_POS+1,EPG_INFO_TEXT_POS+(line*EPG_INFO_FONT_HEIGHT)+EPG_INFO_FONT_HEIGHT+3, EPG_INFO_TEXT_WIDTH, text_line.c_str(), CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
                        if ( m_infoBoxText[pos] == '\n' )
                                pos++; // remove new line
                }
                displayUpdate();
        }
#endif
}
int main(void) {
	DDRD = 0xff;
	DDRB = 0xff;
	DDRC = 0;
	
	PORTC = _BV(2) | _BV(3) | _BV(4) | _BV(5);	// keyboard pull-up
	

	TCCR1A = 0;
	TCCR1B = _BV(CS11) | _BV(CS10);
	
	TIMSK = _BV(OCIE1A);
	
	sei();
	enableLed(false);
	enablePower(false);
	displayOutTime(0);
	
	timer_interval = eeprom_read_word(EEPROM_OFFSET_TIME);
	if (timer_interval > MAX_TIME_INTERVAL_MINUTES || timer_interval == 0) {
		timer_interval = 10;
	}
	
    while(1) {
		keyboardCheck();
		if (timer_mode == TIMER_MODE_WAIT) {
			if (key_pressed[KEY_PLUS] == 0xff && timer_interval < MAX_TIME_INTERVAL_MINUTES) {
				timer_interval++;
				key_pressed[KEY_PLUS] = 220;
			} else if (key_pressed[KEY_MINUS] == 0xff && timer_interval > 0) {
				timer_interval--;
				key_pressed[KEY_MINUS] = 220;
			}
		}
		for (uint8_t i = 0; i < 8; i++) {
			displayUpdate(i);
			if (timer_mode == TIMER_MODE_RUN) {
				displayOutTime(time);
				displayOutSeparator(hsec < 50);
				if (time < 30) {
					enableLed(hsec < 25 || (hsec > 50 && hsec < 75));	
				} else if (time < 60) {
					enableLed(hsec < 75);
				}
			} else {
				displayOutTime(timer_interval);
				displayOutSeparator(true);
				//displayOutSeparator(hsec < 25 || (hsec > 50 && hsec < 75));
				//if (hsec < 25 || (hsec > 50 && hsec < 75)) {
					//displayOutTime(timer_interval);
					//displayOutSeparator(true);
				//} else {
					//displayClear();
				//}
			}
			_delay_us(500);
		}
    }
}
Example #5
0
void CLCD::showRCLock(int duration)
{
	std::string icon = DATADIR "/lcdd/icons/rclock.raw";
	raw_display_t curr_screen;

	// Saving the whole screen is not really nice since the clock is updated
	// every second. Restoring the screen can cause a short travel to the past ;)
	display.dump_screen(&curr_screen);
	display.draw_fill_rect (-1, 10, LCD_COLS, 50, CLCDDisplay::PIXEL_OFF);
	display.paintIcon(icon,44,25,false);
	wake_up();
	displayUpdate();
	sleep(duration);
	display.load_screen(&curr_screen);
	wake_up();
	displayUpdate();
}
Example #6
0
void HttpFileTransfer::receivedResponse(const QString &response)
{
	m_lHeaders.clear();
	m_lHeaders.append(response);
	m_szStatusString = __tr2qs_ctx("Transferring data (%1)","http").arg(response);
	m_tTransferStartTime = kvi_unixTime();
	m_eGeneralStatus = Downloading;
	displayUpdate();
}
Example #7
0
void ParamDialog::on_paramView_clicked(const QModelIndex &index)
{
    nDialog->hide();
    editItem = 0;
    QModelIndex p = index.parent();
    if(p.isValid()) {
        treeItem = index.row()+1;
    } else if(index.row() == 0) {
        treeItem = 0;
    }
    displayUpdate();
}
Example #8
0
void CLCD::showMenuText(const int position, const char * text, const int highlight, const bool utf_encoded)
{
	if (mode != MODE_MENU_UTF8)
		return;

	// reload specified line
	display.draw_fill_rect(-1, 35+14*position, LCD_COLS, 35+14+14*position, CLCDDisplay::PIXEL_OFF);
	fonts.menu->RenderString(0,35+11+14*position, LCD_COLS + 20, text, CLCDDisplay::PIXEL_INV, highlight, utf_encoded);
	wake_up();
	displayUpdate();

}
Example #9
0
void ParamDialog::on_saveAsButton_clicked()
{
    KeyboardDialog kd(this);
    if(kd.exec() == QDialog::Accepted) {
        name = kd.getText();
        QFile file(SystemBase::path + name + QString(".") + SystemBase::postfix);
        param->writeParam(SystemBase::reagentNum, file);
        treeModel->setHorizontalHeaderLabels(QStringList(name));
        displayUpdate();
        isChanged = false;
    }
}
Example #10
0
void CLCD::showAudioPlayMode(const PLAYMODES m)
{
	display.draw_fill_rect (-1,51,10,62, CLCDDisplay::PIXEL_OFF);
	switch(m)
	{
		case PLAYMODE_PLAY:
			{
				int x=3,y=53;
				display.draw_line(x  ,y  ,x  ,y+8, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+1,y+1,x+1,y+7, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+2,y+2,x+2,y+6, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+3,y+3,x+3,y+5, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+4,y+4,x+4,y+4, CLCDDisplay::PIXEL_ON);
				break;
			}
		case PLAYMODE_STOP:
			display.draw_fill_rect (1, 53, 8 ,61, CLCDDisplay::PIXEL_ON);
			break;
		case PLAYMODE_PAUSE:
			display.draw_line(1,54,1,60, CLCDDisplay::PIXEL_ON);
			display.draw_line(2,54,2,60, CLCDDisplay::PIXEL_ON);
			display.draw_line(6,54,6,60, CLCDDisplay::PIXEL_ON);
			display.draw_line(7,54,7,60, CLCDDisplay::PIXEL_ON);
			break;
		case PLAYMODE_FF:
			{
				int x=2,y=55;
				display.draw_line(x   ,y   , x  , y+4, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+1 ,y+1 , x+1, y+3, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+2 ,y+2 , x+2, y+2, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+3 ,y   , x+3, y+4, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+4 ,y+1 , x+4, y+3, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+5 ,y+2 , x+5, y+2, CLCDDisplay::PIXEL_ON);
			}
			break;
		case PLAYMODE_REV:
			{
				int x=2,y=55;
				display.draw_line(x   ,y+2 , x  , y+2, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+1 ,y+1 , x+1, y+3, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+2 ,y   , x+2, y+4, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+3 ,y+2 , x+3, y+2, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+4 ,y+1 , x+4, y+3, CLCDDisplay::PIXEL_ON);
				display.draw_line(x+5 ,y   , x+5, y+4, CLCDDisplay::PIXEL_ON);
			}
			break;
	}
	wake_up();
	displayUpdate();
}
Example #11
0
ParamDialog::ParamDialog(QWidget *parent) :
    BaseDialog(parent),
    ui(new Ui::ParamDialog),
    nDialog(new NumberDialog(this)), param(NULL),
    name(), treeItem(0), editItem(0), isChanged(false)
{
    ui->setupUi(this);
    nDialog->move(parent->x()+570, parent->y()+130);
    connect(nDialog, SIGNAL(outValue()), this, SLOT(nDialogOutValueSLOT()));

    QIcon icon1(":/param/treeView1.png");
    QIcon icon2(":/param/treeView2.png");
    treeModel = new QStandardItemModel(ui->paramView);
    QStandardItem *item1 = new QStandardItem(icon1, QObject::tr("样本过滤设置"));
    treeModel->appendRow(item1);
    QStandardItem *item2 = new QStandardItem(icon1, QObject::tr("试剂设置"));
    treeModel->appendRow(item2);
    QFont font = item1->font();
    font.setPointSize(12);
    item1->setFont(font);
    item2->setFont(font);
    for(int i = 0; i < SystemBase::reagentNum; ++i) {
        QStandardItem *item = new QStandardItem(icon2, QObject::tr("试剂")+QString::number(i+1));
        item2->appendRow(item);
    }
    ui->paramView->setModel(treeModel);
    ui->paramView->expandAll();

    QDir dir(SystemBase::path);
    if(!dir.exists())
        dir.mkdir(SystemBase::path);
    QFile file(SystemBase::path + QString("/") + SystemBase::postfix);
    if(file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&file);
        QString str = in.readLine();
        QFile f(SystemBase::path + str + QString(".") + SystemBase::postfix);
        if(f.exists()) {
            name = str;
            param = new ParamData(SystemBase::reagentNum, f);
            goto label;
        }
        file.close();
    }
    ui->paramView->setEnabled(false);
    ui->saveButton->setEnabled(false);
    ui->saveAsButton->setEnabled(false);
label:
    treeModel->setHorizontalHeaderLabels(QStringList(name));
    displayUpdate();
}
Example #12
0
void ParamDialog::saveCheck(void)
{
    if(param != NULL && isChanged) {
        QFile file(SystemBase::path + name + QString(".") + SystemBase::postfix);
        if(QMessageBox::warning(this, QObject::tr("提示"), QObject::tr("当前配置已经更改,是否保存当前更改?"), QMessageBox::Yes, QMessageBox::No)
                == QMessageBox::Yes) {
            param->writeParam(SystemBase::reagentNum, file);
        } else {
            param->readParam(SystemBase::reagentNum, file);
            displayUpdate();
        }
    }
    isChanged = false;
}
Example #13
0
void CVFD::showProgressBar(int global, const char * const text,int show_escape,int timer)
{
#ifdef HAVE_LCD
	if(!has_lcd) return;
        if(text != NULL)
                m_progressHeaderGlobal = text;

        if(timer != -1)
                m_infoBoxTimer = timer;

        if(global >= 0)
        {
                if(global > 100)
                        m_progressGlobal =100;
                else
                        m_progressGlobal = global;
        }

        if(show_escape != -1)
                m_progressShowEscape = show_escape;

        if (mode == MODE_PROGRESSBAR)
        {
                //printf("[lcdd] prog:%s,%d,%d\n",m_progressHeaderGlobal.c_str(),m_progressGlobal,m_progressShowEscape);
                // Clear Display
                display.draw_fill_rect (0,12,120,64, CLCDDisplay::PIXEL_OFF);

                // paint progress header
                int width = fonts.menu->getRenderWidth(m_progressHeaderGlobal.c_str(),true);
                if(width > 100)
                        width = 100;
                int start_pos = (120-width) /2;
                fonts.menu->RenderString(start_pos, 12+12, width+10, m_progressHeaderGlobal.c_str(), CLCDDisplay::PIXEL_ON,0,true);

                // paint global bar
                int marker_length = (PROG_GLOB_POS_WIDTH * m_progressGlobal)/100;

                display.draw_fill_rect (PROG_GLOB_POS_X,                                 PROG_GLOB_POS_Y,   PROG_GLOB_POS_X+PROG_GLOB_POS_WIDTH,   PROG_GLOB_POS_Y+PROG_GLOB_POS_HEIGTH,   CLCDDisplay::PIXEL_ON);
                display.draw_fill_rect (PROG_GLOB_POS_X+1+marker_length, PROG_GLOB_POS_Y+1, PROG_GLOB_POS_X+PROG_GLOB_POS_WIDTH-1, PROG_GLOB_POS_Y+PROG_GLOB_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF);

                // paint foot
                if(m_progressShowEscape  == true)
                {
                        fonts.menu->RenderString(90, 64, 40, "Home", CLCDDisplay::PIXEL_ON);
                }
                displayUpdate();
        }
#endif
}
Example #14
0
void Keyboard::loopTask(){
  // states
  if(DEVICE_STATE_Configured!=USB_DeviceState){
    KeyboardReport=NULL;
    LEDReport=NO_LED_REPORT;
  }

  // display
  if(USB_DeviceState!=last_USB_DeviceState){
    last_USB_DeviceState=USB_DeviceState;
    displayForceUpdate();
  }
  if(USB_DeviceState==DEVICE_STATE_Suspended){
    if(USB_Device_RemoteWakeupEnabled!=last_USB_Device_RemoteWakeupEnabled)
      displayForceUpdate();
    last_USB_Device_RemoteWakeupEnabled=USB_Device_RemoteWakeupEnabled;
  }
  displayUpdate();

  // scan keys during suspend
  if(DEVICE_STATE_Suspended==USB_DeviceState)
    if(USB_Device_RemoteWakeupEnabled)
      scanAll();
#ifdef SERIAL_DEBUG
  static uint8_t l;
  if(layout!=l){
    l=layout;
    switch(l){
      case 0:
        fprintf(Stream, "US_US\r\n");
        break;
      case 1:
        fprintf(Stream, "US_DVORAK\r\n");
        break;
      case 2:
        fprintf(Stream, "ABNT2_US\r\n");
        break;
      case 3:
        fprintf(Stream, "ABNT2_DVORAK\r\n");
        break;
      case 4:
        fprintf(Stream, "DVORAK_DVORAK\r\n");
        break;
    }
  }
#endif
}
Example #15
0
void CLCD::showAudioTrack(const std::string & artist, const std::string & title, const std::string & album)
{
	if (mode != MODE_AUDIO) 
	{
		return;
	}

	// reload specified line
	display.draw_fill_rect (-1, 10, LCD_COLS, 24, CLCDDisplay::PIXEL_OFF);
	display.draw_fill_rect (-1, 20, LCD_COLS, 37, CLCDDisplay::PIXEL_OFF);
	display.draw_fill_rect (-1, 33, LCD_COLS, 50, CLCDDisplay::PIXEL_OFF);
	fonts.menu->RenderString(0, 22, LCD_COLS + 5, artist.c_str(), CLCDDisplay::PIXEL_ON, 0, isUTF8(artist));
	fonts.menu->RenderString(0, 35, LCD_COLS + 5, album.c_str(),  CLCDDisplay::PIXEL_ON, 0, isUTF8(album));
	fonts.menu->RenderString(0, 48, LCD_COLS + 5, title.c_str(),  CLCDDisplay::PIXEL_ON, 0, isUTF8(title));
	wake_up();
	displayUpdate();

}
Example #16
0
void CLCD::showAudioTrack(const std::string & artist, const std::string & title, const std::string & album)
{
	if (mode != MODE_AUDIO) 
	{
		return;
	}

	// reload specified line
	display.draw_fill_rect (-1,10,121,24, CLCDDisplay::PIXEL_OFF);
	display.draw_fill_rect (-1,20,121,37, CLCDDisplay::PIXEL_OFF);
	display.draw_fill_rect (-1,33,121,50, CLCDDisplay::PIXEL_OFF);
	fonts.menu->RenderString(0,22, 125, artist.c_str() , CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
	fonts.menu->RenderString(0,35, 125, album.c_str() , CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
	fonts.menu->RenderString(0,48, 125, title.c_str() , CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
	wake_up();
	displayUpdate();

}
Example #17
0
void HttpFileTransfer::requestSent(const QStringList &requestHeaders)
{
	m_szStatusString = __tr2qs_ctx("Request sent: waiting for reply...","http");
	displayUpdate();

	KviWindow * out = transferWindow();
	if(!out)return;

	if(!m_bNoOutput)
		out->output(KVI_OUT_GENERICSTATUS,__tr2qs_ctx("[HTTP %d]: Request data sent:","http"),id());

	for(QStringList::ConstIterator it = requestHeaders.begin();it != requestHeaders.end();++it)
	{
		if(!m_bNoOutput)
			out->output(KVI_OUT_GENERICSTATUS,"[HTTP %d]:   %s",id(),(*it).toUtf8().data());
	}

	m_lRequest = requestHeaders;
}
Example #18
0
void ParamDialog::on_newButton_clicked()
{
    saveCheck();
    KeyboardDialog kd(this);
    if(kd.exec() == QDialog::Accepted) {
        if(param != NULL)
            delete param;

        name = kd.getText();
        param = new ParamData(SystemBase::reagentNum);
        treeModel->setHorizontalHeaderLabels(QStringList(name));
        displayUpdate();
        isChanged = true;

        ui->paramView->setEnabled(true);
        ui->saveButton->setEnabled(true);
        ui->saveAsButton->setEnabled(true);
    }
}
Example #19
0
void CLCD::showAudioProgress(const char perc, bool isMuted)
{
	if (mode == MODE_AUDIO)
	{
		display.draw_fill_rect (11,53,73,61, CLCDDisplay::PIXEL_OFF);
		int dp = int( perc/100.0*61.0+12.0);
		display.draw_fill_rect (11,54,dp,60, CLCDDisplay::PIXEL_ON);
		if(isMuted)
		{
			if(dp > 12)
			{
				display.draw_line(12, 56, dp-1, 56, CLCDDisplay::PIXEL_OFF);
				display.draw_line(12, 58, dp-1, 58, CLCDDisplay::PIXEL_OFF);
			}
			else
				display.draw_line (12,55,72,59, CLCDDisplay::PIXEL_ON);
		}
		displayUpdate();
	}
}
Example #20
0
void ParamDialog::on_openButton_clicked()
{
    saveCheck();
    FileListDialog fd(this, SystemBase::path, QString(".") + SystemBase::postfix);
    if(fd.exec() == QDialog::Accepted) {
        name = fd.selectedFile();
        QFile file(SystemBase::path + name + QString(".") + SystemBase::postfix);
        if(param) {
            param->readParam(SystemBase::reagentNum, file);
        } else {
            param = new ParamData(SystemBase::reagentNum, file);
        }
        treeModel->setHorizontalHeaderLabels(QStringList(name));
        displayUpdate();

        ui->paramView->setEnabled(true);
        ui->saveButton->setEnabled(true);
        ui->saveAsButton->setEnabled(true);
    }
}
Example #21
0
void CLCD::showTime()
{
	if (showclock)
	{
		char timestr[21];
		struct timeval tm;
		struct tm * t;

		gettimeofday(&tm, NULL);
		t = localtime(&tm.tv_sec);

		if (mode == MODE_STANDBY)
		{
			display.draw_fill_rect(-1, -1, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); // clear lcd

			ShowNewClock(&display, t->tm_hour, t->tm_min, t->tm_sec, t->tm_wday, t->tm_mday, t->tm_mon, CNeutrinoApp::getInstance()->recordingstatus);
		}
		else
		{
			if (CNeutrinoApp::getInstance ()->recordingstatus && clearClock == 1)
			{
				strcpy(timestr,"  :  ");
				clearClock = 0;
			}
			else
			{
				strftime((char*) &timestr, 20, "%H:%M", t);
				clearClock = 1;
			}

			display.draw_fill_rect (77, 50, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF);

			fonts.time->RenderString(122 - fonts.time->getRenderWidth(timestr), 62, 50, timestr, CLCDDisplay::PIXEL_ON);
		}
		displayUpdate();
	}
}
void CLCD::showMenuText(const int position, const char * text, const int highlight, const bool utf_encoded)
{
	/* hack, to not have to patch too much in movieplayer.cpp */
	if (mode == MODE_MOVIE) {
		size_t p;
		AUDIOMODES m = movie_playmode;
		std::string mytext = text;
		if (mytext.find("> ") == 0) {
			mytext = mytext.substr(2);
			m = AUDIO_MODE_PLAY;
		} else if (mytext.find("|| ") == 0) {
			mytext = mytext.substr(3);
			m = AUDIO_MODE_PAUSE;
		} else if ((p = mytext.find("s||> ")) < 3) {
			mytext = mytext.substr(p + 5);
			m = AUDIO_MODE_PLAY;
		} else if ((p = mytext.find("x>> ")) < 3) {
			mytext = mytext.substr(p + 4);
			m = AUDIO_MODE_FF;
		} else if ((p = mytext.find("x<< ")) < 3) {
			mytext = mytext.substr(p + 4);
			m = AUDIO_MODE_REV;
		}
		setMovieInfo(m, "", mytext, false);
		return;
	}

	if (mode != MODE_MENU_UTF8)
		return;

	// reload specified line
	display.draw_fill_rect(-1, 35+14*position, LCD_COLS, 35+14+14*position, CLCDDisplay::PIXEL_OFF);
	fonts.menu->RenderString(0,35+11+14*position, LCD_COLS + 20, text, CLCDDisplay::PIXEL_INV, highlight, utf_encoded);
	wake_up();
	displayUpdate();

}
Example #23
0
void CLCD::showPercentOver(const unsigned char perc, const bool perform_update, const MODES m)
{
	bool tsmode = (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_ts);
	if (m == MODE_TVRADIO && tsmode || m == MODE_MOVIE && !tsmode)
		return;

	percentOver = perc;
	if (mode == MODE_TVRADIO || mode == MODE_MOVIE)
	{
		int left, top, width, height = 5;
		bool draw = true;

		if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == STATUSLINE_PLAYTIME)
		{
			left = 12; top = 55; width = 60;
		}
		else if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == STATUSLINE_BOTH)
		{
			left = 12; top = 3; width = 104;
		}
		else if (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME] == STATUSLINE_BOTH_AUDIO)
		{
			left = 12; top = 3; width = 84;

			if ((g_RemoteControl != NULL && mode == MODE_TVRADIO) || mode == MODE_MOVIE)
			{
				bool is_ac3;
				if (mode == MODE_MOVIE)
					is_ac3 = movie_is_ac3;
				else
				{
					uint count = g_RemoteControl->current_PIDs.APIDs.size();
					if ((g_RemoteControl->current_PIDs.PIDs.selected_apid < count) &&
					    (g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].is_ac3))
						is_ac3 = true;
					else
						is_ac3 = false;
				}

				const char * icon;
				if (is_ac3)
					icon = DATADIR "/lcdd/icons/" NEUTRINO_ICON_DD;
				else
					icon = DATADIR "/lcdd/icons/stereo.raw";

				display.paintIcon(icon, 101, 1, false);
			}
		}
		else
			draw = false;

		if (draw)
		{
			display.draw_fill_rect (left-1, top-1, left+width+1, top+height, CLCDDisplay::PIXEL_OFF);
			if (perc == (unsigned char) -1)
			{
				display.draw_line (left, top, left+width, top+height-1, CLCDDisplay::PIXEL_ON);
			}
			else
			{
				int dp;
				if (perc == (unsigned char) -2)
					dp = width+1;
				else
					dp = perc * (width + 1) / 100;
				display.draw_fill_rect (left-1, top-1, left+dp, top+height, CLCDDisplay::PIXEL_ON);

				if (perc == (unsigned char) -2)
				{
					// draw a "+" to show that the event is overdue
					display.draw_line(left+width-2, top+1, left+width-2, top+height-2, CLCDDisplay::PIXEL_OFF);
					display.draw_line(left+width-1, top+(height/2), left+width-3, top+(height/2), CLCDDisplay::PIXEL_OFF);
				}
			}
		}

		if (perform_update)
			displayUpdate();
	}
}
Example #24
0
void HttpFileTransfer::contactingHost(const QString &ipandport)
{
	m_szStatusString = __tr2qs_ctx("Contacting host %1","http").arg(ipandport);
	displayUpdate();
}
Example #25
0
void CLCD::showProgressBar2(int local,const char * const text_local ,int global ,const char * const text_global ,int show_escape )
{
	//printf("[lcdd] prog2\n");
	if(text_local != NULL)
		m_progressHeaderLocal = text_local;
		
	if(text_global != NULL)
		m_progressHeaderGlobal = text_global;
		
	if(global >= 0)
	{
		if(global > 100)
			m_progressGlobal =100;
		else
			m_progressGlobal = global;
	}
	
	if(local >= 0)
	{
		if(local > 100)
			m_progressLocal =100;
		else
			m_progressLocal = local;
	}
	
	if(show_escape != -1)
		m_progressShowEscape = show_escape;

	if (mode == MODE_PROGRESSBAR2)
	{
		//printf("[lcdd] prog2:%s,%d,%d\n",m_progressHeaderGlobal.c_str(),m_progressGlobal,m_progressShowEscape);
		// Clear Display
		display.draw_fill_rect (0, 12, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF);
		
	
		// paint  global caption 
		int width = fonts.menu->getRenderWidth(m_progressHeaderGlobal.c_str(),true);
		if(width > 100)
			width = 100;
		int start_pos = (LCD_COLS - width) /2;
		fonts.menu->RenderString(start_pos, PROG2_GLOB_POS_Y+20, width+10, m_progressHeaderGlobal.c_str(), CLCDDisplay::PIXEL_ON,0,true);
	
		// paint global bar 
		int marker_length = (PROG2_GLOB_POS_WIDTH * m_progressGlobal)/100;
		
		display.draw_fill_rect (PROG2_GLOB_POS_X,   				PROG2_GLOB_POS_Y,   PROG2_GLOB_POS_X+PROG2_GLOB_POS_WIDTH,   PROG2_GLOB_POS_Y+PROG2_GLOB_POS_HEIGTH,   CLCDDisplay::PIXEL_ON);
		display.draw_fill_rect (PROG2_GLOB_POS_X+1+marker_length, PROG2_GLOB_POS_Y+1, PROG2_GLOB_POS_X+PROG2_GLOB_POS_WIDTH-1, PROG2_GLOB_POS_Y+PROG2_GLOB_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF);
	
		
		// paint  local caption 
		width = fonts.menu->getRenderWidth(m_progressHeaderLocal.c_str(),true);
		if(width > 100)
			width = 100;
		start_pos = (LCD_COLS - width) /2;
		fonts.menu->RenderString(start_pos, PROG2_LOCAL_POS_Y -3, width+10, m_progressHeaderLocal.c_str(), CLCDDisplay::PIXEL_ON,0,true);
		// paint local bar 
		marker_length = (PROG2_LOCAL_POS_WIDTH * m_progressLocal)/100;
		
		display.draw_fill_rect (PROG2_LOCAL_POS_X,   				PROG2_LOCAL_POS_Y,   PROG2_LOCAL_POS_X+PROG2_LOCAL_POS_WIDTH,   PROG2_LOCAL_POS_Y+PROG2_LOCAL_POS_HEIGTH,   CLCDDisplay::PIXEL_ON);
		display.draw_fill_rect (PROG2_LOCAL_POS_X+1+marker_length,   PROG2_LOCAL_POS_Y+1, PROG2_LOCAL_POS_X+PROG2_LOCAL_POS_WIDTH-1, PROG2_LOCAL_POS_Y+PROG2_LOCAL_POS_HEIGTH-1, CLCDDisplay::PIXEL_OFF);
		
		
		// paint foot 
		if(m_progressShowEscape  == true)
		{
			fonts.menu->RenderString(90, 64, 40, "Home", CLCDDisplay::PIXEL_ON);
		}
		displayUpdate();
	}
}
Example #26
0
void HttpFileTransfer::resolvingHost(const QString &hostname)
{
	m_szStatusString = __tr2qs_ctx("Resolving host %1","http").arg(hostname);
	displayUpdate();
}
Example #27
0
void HttpFileTransfer::connectionEstabilished()
{
	m_szStatusString = __tr2qs_ctx("Connection established: sending request","http");
	displayUpdate();
}
Example #28
0
/* display "big" and "small" text.
   TODO: right now, "big" is hardcoded as utf-8, small is not (for EPG)
 */
void CLCD::showTextScreen(const std::string & big, const std::string & small, const int showmode, const bool perform_wakeup)
{
	/* the "showmode" variable is a bit map:
		EPG_NAME	show "big" string
		EPG_SHORT	show only one line of "big" string
		EPG_TITLE	show "small" string
		EPG_SEPLINE	show separator line if big and small are present / shown
	 */

	/* draw_fill_rect is braindead: it actually fills _inside_ the described rectangle,
	   so that you have to give it one pixel additionally in every direction ;-(
	   this is where the "-1 to 120" intead of "0 to 119" comes from */
	display.draw_fill_rect(-1, 10, LCD_COLS, 51, CLCDDisplay::PIXEL_OFF);

	bool big_utf8 = false;
	bool small_utf8 = false;
	std::string cname[2];
	std::string event[4];
	int namelines = 0, eventlines = 0, maxnamelines = 2;
	if (showmode & EPG_SHORT)
		maxnamelines = 1;

	if ((showmode & EPG_NAME) && !big.empty())
	{
		bool dumb = false;
		big_utf8 = isUTF8(big);
		while (true)
		{
			namelines = 0;
			std::string title = big;
			do { // first try "intelligent" splitting
				cname[namelines] = splitString(title, LCD_COLS, fonts.channelname, dumb, big_utf8);
				title = removeLeadingSpaces(title.substr(cname[namelines].length()));
				namelines++;
			} while (!title.empty() && namelines < maxnamelines);
			if (title.empty())
				break;
			dumb = !dumb;	// retry with dumb splitting;
			if (!dumb)	// second retry -> get out;
				break;
		}
	}

	// one nameline => 2 eventlines, 2 namelines => 1 eventline
	int maxeventlines = 4 - (namelines * 3 + 1) / 2;

	if ((showmode & EPG_TITLE) && !small.empty())
	{
		bool dumb = false;
		small_utf8 = isUTF8(small);
		while (true)
		{
			eventlines = 0;
			std::string title = small;
			do { // first try "intelligent" splitting
				event[eventlines] = splitString(title, LCD_COLS, fonts.menu, dumb, small_utf8);
				title = removeLeadingSpaces(title.substr(event[eventlines].length()));
				/* DrDish TV appends a 0x0a to the EPG title. We could strip it in sectionsd...
				   ...instead, strip all control characters at the end of the text for now */
				if (!event[eventlines].empty() && event[eventlines].at(event[eventlines].length() - 1) < ' ')
					event[eventlines].erase(event[eventlines].length() - 1);
				eventlines++;
			} while (!title.empty() && eventlines < maxeventlines);
			if (title.empty())
				break;
			dumb = !dumb;	// retry with dumb splitting;
			if (!dumb)	// second retry -> get out;
				break;
		}
	}

	/* this values were determined empirically */
	int y = 8 + (41 - namelines*14 - eventlines*10)/2;
	int x = 1;
	for (int i = 0; i < namelines; i++) {
		y += 14;
		if (g_settings.lcd_setting[SNeutrinoSettings::LCD_EPGALIGN] == EPGALIGN_CENTER)
		{
			int w = fonts.channelname->getRenderWidth(cname[i].c_str(), big_utf8);
			x = (LCD_COLS - w) / 2;
		}
		fonts.channelname->RenderString(x, y, LCD_COLS + 10, cname[i].c_str(), CLCDDisplay::PIXEL_ON, 0, big_utf8);
	}
	y++;
	if (eventlines > 0 && namelines > 0 && (showmode & EPG_SEPLINE))
	{
		y++;
		display.draw_line(0, y, LCD_COLS - 1, y, CLCDDisplay::PIXEL_ON);
	}
	if (eventlines > 0)
	{
		for (int i = 0; i < eventlines; i++) {
			y += 10;
			if (g_settings.lcd_setting[SNeutrinoSettings::LCD_EPGALIGN] == EPGALIGN_CENTER)
			{
				int w = fonts.menu->getRenderWidth(event[i].c_str(), small_utf8);
				x = (LCD_COLS - w) / 2;
			}
			fonts.menu->RenderString(x, y, LCD_COLS + 10, event[i].c_str(), CLCDDisplay::PIXEL_ON, 0, small_utf8);
		}
	}

	if (perform_wakeup)
		wake_up();

	displayUpdate();
}
MainWindowController::MainWindowController(
    QWidget *parent,
    QString logPathOverride,
    QString dbPathOverride,
    QString scriptPath)
    : QMainWindow(parent),
      ui(new Ui::MainWindowController),
      togglApi(new TogglApi(0, logPathOverride, dbPathOverride)),
      tracking(false),
      loggedIn(false),
      actionEmail(0),
      actionNew(0),
      actionContinue(0),
      actionStop(0),
      actionSync(0),
      actionLogout(0),
      actionClear_Cache(0),
      actionSend_Feedback(0),
      actionReports(0),
      preferencesDialog(new PreferencesDialog(this)),
      aboutDialog(new AboutDialog(this)),
      feedbackDialog(new FeedbackDialog(this)),
      idleNotificationDialog(new IdleNotificationDialog(this)),
      trayIcon(0),
      reminder(false),
      pomodoro(false),
      script(scriptPath),
      ui_started(false) {
    TogglApi::instance->setEnvironment(APP_ENVIRONMENT);

    ui->setupUi(this);

    ui->menuBar->setVisible(true);

    QVBoxLayout *verticalLayout = new QVBoxLayout();
    verticalLayout->addWidget(new ErrorViewController());
    verticalLayout->addWidget(new LoginWidget());
    verticalLayout->addWidget(new TimeEntryListWidget());
    verticalLayout->addWidget(new TimeEntryEditorWidget());
    verticalLayout->setContentsMargins(0, 0, 0, 0);
    verticalLayout->setSpacing(0);
    centralWidget()->setLayout(verticalLayout);

    readSettings();

    connect(TogglApi::instance, SIGNAL(displayApp(bool)),  // NOLINT
            this, SLOT(displayApp(bool)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayStoppedTimerState()),  // NOLINT
            this, SLOT(displayStoppedTimerState()));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayRunningTimerState(TimeEntryView*)),  // NOLINT
            this, SLOT(displayRunningTimerState(TimeEntryView*)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayLogin(bool,uint64_t)),  // NOLINT
            this, SLOT(displayLogin(bool,uint64_t)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayReminder(QString,QString)),  // NOLINT
            this, SLOT(displayReminder(QString,QString)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayUpdate(QString)),  // NOLINT
            this, SLOT(displayUpdate(QString)));  // NOLINT

    connect(TogglApi::instance, SIGNAL(displayOnlineState(int64_t)),  // NOLINT
            this, SLOT(displayOnlineState(int64_t)));  // NOLINT


    hasTrayIconCached = hasTrayIcon();
    if (hasTrayIconCached) {
        icon.addFile(QString::fromUtf8(":/icons/1024x1024/toggldesktop.png"));

        iconDisabled.addFile(QString::fromUtf8(
                                 ":/icons/1024x1024/toggldesktop_gray.png"));

        trayIcon = new QSystemTrayIcon(this);
    }

    connectMenuActions();
    enableMenuActions();

    if (hasTrayIconCached) {
        // icon is set in enableMenuActions based on if tracking is in progress
        trayIcon->show();
    } else {
        setWindowIcon(icon);
    }
}
Example #30
0
void CLCD::setMode(const MODES m, const char * const title)
{
	mode = m;
	menutitle = title;
	setlcdparameter();

	switch (m)
	{
	case MODE_TVRADIO:
	case MODE_MOVIE:
		switch (g_settings.lcd_setting[SNeutrinoSettings::LCD_SHOW_VOLUME])
		{
		case STATUSLINE_PLAYTIME:
			display.load_screen(&(background[BACKGROUND_LCD2]));
			showPercentOver(percentOver, false, mode);
			break;
		case STATUSLINE_VOLUME:
			display.load_screen(&(background[BACKGROUND_LCD]));
			showVolume(volume, false);
			break;
		case STATUSLINE_BOTH:
			display.load_screen(&(background[BACKGROUND_LCD3]));
			showVolume(volume, false);
			showPercentOver(percentOver, false, mode);
			break;
		case STATUSLINE_BOTH_AUDIO:
			display.load_screen(&(background[BACKGROUND_LCD4]));
			showVolume(volume, false);
			showPercentOver(percentOver, false, mode);
			break;
		default:
			break;
		}
		if (mode == MODE_TVRADIO)
			showServicename(servicename);
		else
		{
			setMoviePlaymode(movie_playmode);
			setMovieInfo(movie_big, movie_small);
			setMovieAudio(movie_is_ac3);
		}
		showclock = true;
		showTime();      /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */
		break;
	case MODE_AUDIO:
	{
		display.load_screen(&(background[BACKGROUND_LCD]));
		display.draw_fill_rect(0, 14, LCD_COLS, 48, CLCDDisplay::PIXEL_OFF);
		
		showAudioPlayMode(PLAYMODE_STOP);
		showVolume(volume, false);
		showclock = true;
		showTime();      /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */
		break;
	}
	case MODE_SCART:
		display.load_screen(&(background[BACKGROUND_LCD]));
		showVolume(volume, false);
		showclock = true;
		showTime();      /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */
		break;
	case MODE_MENU_UTF8:
		showclock = false;
		display.load_screen(&(background[BACKGROUND_SETUP]));
		fonts.menutitle->RenderString(0, 28, LCD_COLS + 20, title, CLCDDisplay::PIXEL_ON, 0, true); // UTF-8
		displayUpdate();
		break;
	case MODE_SHUTDOWN:
		showclock = false;
		display.load_screen(&(background[BACKGROUND_POWER]));
		displayUpdate();
		break;
	case MODE_STANDBY:
		showclock = true;
		showTime();      /* "showclock = true;" implies that "showTime();" does a "displayUpdate();" */
		                 /* "showTime()" clears the whole lcd in MODE_STANDBY                         */
		break;
#ifdef LCD_UPDATE
	case MODE_FILEBROWSER:
		showclock = true;
		display.draw_fill_rect(-1, -1, LCD_COLS, 64, CLCDDisplay::PIXEL_OFF); // clear lcd
		showFilelist();
		break;
	case MODE_PROGRESSBAR:
		showclock = false;
		display.load_screen(&(background[BACKGROUND_SETUP]));
		showProgressBar();
		break;
	case MODE_PROGRESSBAR2:
		showclock = false;
		display.load_screen(&(background[BACKGROUND_SETUP]));
		showProgressBar2();
		break;
	case MODE_INFOBOX:
		showclock = false;
		showInfoBox();
		break;
#endif // LCD_UPDATE
	}
	wake_up();
}