volatile char menuBack(char key, char first)
{
	if(key == FL_KEY)
		menu.back();

	return FN_CANCEL;
}
volatile char shutter_saveAs(char key, char first)
{
	static char name[MENU_NAME_LEN - 1];
	static char newId;

	if(first)
	{
		newId = timer.nextId();

		if(newId < 0)
		{
			menu.message(TEXT("No Space"));
			return FN_CANCEL;
		}
	}

	char ret = menu.editText(key, name, TEXT("Save As"), first);

	if(ret == FN_SAVE)
	{
		name[MENU_NAME_LEN - 2] = 0;
		strcpy((char*)timer.current.Name, name);
		timer.save(newId);
		menu.message(TEXT("Saved"));
		menu.back();
	}

	return ret;
}
volatile char timerRevert(char key, char first)
{
	if(first)
		timer.load(timer.currentId);

	menu.message(TEXT("Reverted"));
	menu.back();
	return FN_CANCEL;
}
volatile char timerSaveCurrent(char key, char first)
{
	if(first)
		timer.save(timer.currentId);

	menu.message(TEXT("Saved"));
	menu.back();
	return FN_CANCEL;
}
volatile char timerSaveDefault(char key, char first)
{
	if(first)
		timer.save(0);

	menu.message(TEXT("Saved"));
	menu.back();
	return FN_CANCEL;
}
volatile char timerStop(char key, char first)
{
	if(first)
		timer.running = 0;

	menu.message(TEXT("Stopped"));
	menu.back();
	return FN_CANCEL;
}
volatile char shutter_removeKeyframe(char key, char first)
{
	if(timer.current.Keyframes > 1)
	{
		timer.current.Keyframes--;
	}

	menu.back();
	menu.select(0);

	return FN_CANCEL;
}
Esempio n. 8
0
void chargingScreen(void)
{
  char first = 1;
  menu.push();
  while(button.get() != FL_KEY && battery_status() > 0)
  {
    wdt_reset();
    batteryStatus(0, first);
    first = 0;
  }
  menu.back();
}
volatile char shutter_addKeyframe(char key, char first)
{
	if(timer.current.Keyframes < MAX_KEYFRAMES)
	{
		if(timer.current.Keyframes < 1)
			timer.current.Keyframes = 1;

		timer.current.Key[timer.current.Keyframes] = timer.current.Key[timer.current.Keyframes - 1] + 3600;
		timer.current.Bulb[timer.current.Keyframes + 1] = timer.current.Bulb[timer.current.Keyframes];
		timer.current.Keyframes++;
	}

	menu.back();

	return FN_CANCEL;
}
volatile char shutter_load(char key, char first)
{
	static char menuSize;
	static char menuSelected;
	static char itemSelected;
	uint8_t c;
	char ch, update, menuScroll;

	update = 0;

	if(first)
	{
		menuScroll = 0;
		update = 1;
	}

	if(key == UP_KEY && menuSelected > 0)
	{
		menuSelected--;
		update = 1;

	}
	else if(key == DOWN_KEY && menuSelected < menuSize - 1)
	{
		menuSelected++;
		update = 1;
	}

	if(update)
	{
		lcd.cls();

		if(menuSelected > 2)
			menuScroll = menuSelected - 2;

		menuSize = 0;
		char i = 0;

		for(char x = 1; x < MAX_STORED; x++)
		{
			i++;
			ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[0]);

			if(ch == 0 || ch == 255)
				continue;

			for(c = 0; c < MENU_NAME_LEN - 1; c++) // Write settings item text //
			{
				if(i >= menuScroll && i <= menuScroll + 5)
				{
					ch = eeprom_read_byte((uint8_t*)&stored[i - 1].Name[c]);

					if(ch == 0) break;

					if(ch < 'A' || ch > 'Z')
						ch = ' ';

					lcd.writeChar(3 + c * 6, 8 + 9 * (menuSize - menuScroll), ch);

					if(menuSize == menuSelected)
						itemSelected = i - 1;
				}
			}
			menuSize++;
		}

		lcd.drawHighlight(2, 7 + 9 * (menuSelected - menuScroll), 81, 7 + 9 * (menuSelected - menuScroll) + 8);

		menu.setTitle(TEXT("Load Saved"));
		menu.setBar(TEXT("CANCEL"), TEXT("LOAD"));

		lcd.drawLine(0, 3, 0, 40);
		lcd.drawLine(83, 3, 83, 40);

		lcd.update();
	}

	switch(key)
	{
	   case FL_KEY:
	   case LEFT_KEY:
		   return FN_CANCEL;

	   case FR_KEY:
	   case RIGHT_KEY:
		   timer.load(itemSelected);
		   menu.message(TEXT("Loaded"));
		   menu.back();
		   menu.select(0);
		   return FN_SAVE;
	}

	return FN_CONTINUE;
}