public void ProcessKey(FEZ_Shields.KeypadLCD.Keys keyPressed) { if (currentLine1.IsProcessingKey()) { currentLine1.ProcessKey(keyPressed); } else if (currentLine2.IsProcessingKey()) { currentLine2.ProcessKey(keyPressed); } else { switch (keyPressed) { case FEZ_Shields.KeypadLCD.Keys.Up: ClearLine(LinesEnum.Line2); if (currentLine2 is WheelSizeDisplayProcessor) { currentLine2 = odoTripCtrl; } else if (currentLine2 is SetTimeDisplayProcessor) { currentLine2 = wheelCtrl; } break; case FEZ_Shields.KeypadLCD.Keys.Down: ClearLine(LinesEnum.Line2); if (currentLine2 is OdometerTripTimeDisplayProcessor) { currentLine2 = wheelCtrl; } else if (currentLine2 is WheelSizeDisplayProcessor) { currentLine2 = setTimeCtrl; } break; case FEZ_Shields.KeypadLCD.Keys.Select: currentLine2.BeginEdit(); break; } } }
public void ProcessKey(FEZ_Shields.KeypadLCD.Keys keyPressed) { return; }
public void ProcessKey(FEZ_Shields.KeypadLCD.Keys keyPressed) { switch (keyPressed) { case FEZ_Shields.KeypadLCD.Keys.Right: editingPosition++; if (editingPosition > EXIT_CHAR_POSITION) { editingPosition = EXIT_CHAR_POSITION; } break; case FEZ_Shields.KeypadLCD.Keys.Left: editingPosition--; if (editingPosition < WHEEL_SIZE_POSITION_0) { editingPosition = WHEEL_SIZE_POSITION_0; } break; case FEZ_Shields.KeypadLCD.Keys.Up: if (editingPosition >= WHEEL_SIZE_POSITION_0 && editingPosition <= WHEEL_SIZE_POSITION_2) { char editedChar = editingText[editingPosition]; if (editedChar != '9') { editedChar++; editingText[editingPosition] = editedChar; } } else if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { approving = EndEditEnum.Cancelling; } else if (approving == EndEditEnum.Cancelling) { approving = EndEditEnum.Approving; } } break; case FEZ_Shields.KeypadLCD.Keys.Down: if (editingPosition >= WHEEL_SIZE_POSITION_0 && editingPosition <= WHEEL_SIZE_POSITION_2) { char editedChar = editingText[editingPosition]; if (editedChar != '0') { editedChar--; editingText[editingPosition] = editedChar; } } else if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { approving = EndEditEnum.Cancelling; } else if (approving == EndEditEnum.Cancelling) { approving = EndEditEnum.Approving; } } break; case FEZ_Shields.KeypadLCD.Keys.Select: if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { string newValue = new string(editingText); bikeData.WheelSize = int.Parse(newValue); } isEditing = false; isInitialised = false; approving = EndEditEnum.NotEditing; } break; } }
public void ProcessKey(FEZ_Shields.KeypadLCD.Keys keyPressed) { switch (keyPressed) { case FEZ_Shields.KeypadLCD.Keys.Right: editingPosition++; if (editingPosition > EXIT_CHAR_POSITION) { editingPosition = EXIT_CHAR_POSITION; } break; case FEZ_Shields.KeypadLCD.Keys.Left: editingPosition--; if (editingPosition < HOUR_POSITION_0) { editingPosition = HOUR_POSITION_0; } break; case FEZ_Shields.KeypadLCD.Keys.Up: if (editingPosition >= HOUR_POSITION_0 && editingPosition <= SECOND_POSITION_1) { char editedChar = editingText[editingPosition]; if (editedChar != '9') { editedChar++; editingText[editingPosition] = editedChar; } } else if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { approving = EndEditEnum.Cancelling; } else if (approving == EndEditEnum.Cancelling) { approving = EndEditEnum.Approving; } } break; case FEZ_Shields.KeypadLCD.Keys.Down: if (editingPosition >= HOUR_POSITION_0 && editingPosition <= SECOND_POSITION_1) { char editedChar = editingText[editingPosition]; if (editedChar != '0') { editedChar--; editingText[editingPosition] = editedChar; } } else if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { approving = EndEditEnum.Cancelling; } else if (approving == EndEditEnum.Cancelling) { approving = EndEditEnum.Approving; } } break; case FEZ_Shields.KeypadLCD.Keys.Select: if (editingPosition == EXIT_CHAR_POSITION) { if (approving == EndEditEnum.Approving) { string strHour = new string(editingText, 0, 2); string strMinute = new string(editingText, 2, 2); string strSecond = new string(editingText, 4, 2); int iHour = int.Parse(strHour); int iMinute = int.Parse(strMinute); int iSecond = int.Parse(strSecond); Utility.SetLocalTime(new DateTime(2011, 01, 01, iHour, iMinute, iSecond, 0)); } isEditing = false; isInitialised = false; approving = EndEditEnum.NotEditing; } break; } }
public static void Main() { //////////////////////////////////////////////////////// // BEGIN Computer variables //////////////////////////////////////////////////////// Utility.SetLocalTime(new DateTime(2011, 01, 01, 12, 0, 0, 0)); // Blink board LED bool blinkLEDState = false; // test blink led OutputPort blinkLED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, blinkLEDState); // Sensor port InterruptPort IntSensorButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di1, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); // add an interrupt handler to the pin IntSensorButton.OnInterrupt += new NativeEventHandler(IntSensorButton_OnInterrupt); // Switch displey on/off port InterruptPort IntDisplayOnOffButton = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di2, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); // add an interrupt handler to the pin IntDisplayOnOffButton.OnInterrupt += new NativeEventHandler(IntDisplayOnOffButton_OnInterrupt); FEZ_Shields.KeypadLCD.Initialize(); bikeData.IsDisplayOn = true; DisplayController display = new DisplayController(bikeData); ///////////////////////////////////////////////////////// // END Computer variables ///////////////////////////////////////////////////////// // Main loop while (true) { // |0123456789012345 // 0|99 km/h 99:99:99 // 1|99.999 km 99:99 // Edit 1 Wheel size: 999> // Edit 2 Time: 99:99:99 > // Reset speedometer if (display.CanEditLine()) { bikeData.lastDisplayUsed = DateTime.Now; } else { TimeSpan lastDisplayUsedSpan = DateTime.Now - bikeData.lastDisplayUsed; if (lastDisplayUsedSpan.Seconds > 5) { bikeData.lastSpeedCheck = DateTime.MinValue; bikeData.CurrentSpeed = 0; bikeData.IsDisplayOn = false; } } // Reset trip timer TimeSpan lastTripCheckSpan = DateTime.Now - bikeData.lastTripCheck; if (lastTripCheckSpan.Minutes > 30) { bikeData.IsStartTripSet = false; bikeData.StartTrip = DateTime.MinValue; } // Sleep for 500 milliseconds Thread.Sleep(500); display.DisplayLines(); FEZ_Shields.KeypadLCD.Keys KeyPressed = FEZ_Shields.KeypadLCD.GetKey(); if (KeyPressed != FEZ_Shields.KeypadLCD.Keys.None) { if (!bikeData.IsDisplayOn) { bikeData.IsDisplayOn = true; } else { display.ProcessKey(KeyPressed); } } // toggle LED state blinkLEDState = !blinkLEDState; blinkLED.Write(blinkLEDState); } }