/// <summary>
        /// Create the User Interface components.
        /// </summary>
        /// <param name="oled">The OLED driver for the display</param>
        /// <param name="leftButton">The pin wired to the left button</param>
        /// <param name="rightButton">The pin wired to the right button</param>
        public SimpleUserInterface(
            Newhaven25664OledDriver oled,
            Cpu.Pin leftButton,
            Cpu.Pin rightButton)
        {
            this.oled = oled;
            this.oled.SetContrast(this.oledContrast[this.oledContrastIndex]);

            // wire up the buttons
            this.leftButton  = new AutoRepeatInputPort(leftButton, Port.ResistorMode.PullUp, false);
            this.rightButton = new AutoRepeatInputPort(rightButton, Port.ResistorMode.PullUp, false);

            this.leftButton.StateChanged  += new AutoRepeatEventHandler(leftButton_OnInterrupt);
            this.rightButton.StateChanged += new AutoRepeatEventHandler(rightButton_OnInterrupt);

            // setup the pages
            this.pages = new Page[] {
                CreateSailingPage(),
                //CreateSpeedPage(),
                CreateWindPage(),
                CreateStopwatchPage()
            };

            this.currentPageIndex = 0;
            this.pages[this.currentPageIndex].Visible();

            // refresh the display
            this.Refresh();

            /*
             * Random r = new Random();
             * double windSpeed = 10;
             * double speedOverGround = 4;
             * double depth = 20;
             * int windDir = 0;
             * while (true)
             * {
             *  windSpeed += r.NextDouble() - 0.5;
             *  speedOverGround += r.NextDouble() - 0.5;
             *  depth += (r.NextDouble() * 12) - 5;
             *  windDir = (windDir + r.Next(4) - 2) % 360;
             *  if (windDir < 0) windDir += 360;
             *  DisplayVariables.WindSpeed.Value = windSpeed;
             *  DisplayVariables.SpeedOverGround.Value = speedOverGround;
             *  DisplayVariables.WindDirection.Value = windDir;
             *  DisplayVariables.Depth.Value = depth;
             *  DebugLog.WriteLine("hi");
             *  Thread.Sleep(100);
             * }
             */
        }
 public StopwatchPage(Newhaven25664OledDriver oled) : base(oled)
 {
     this.m_timer = new Timer(new TimerCallback(UpdateDisplayCallback), null, Timeout.Infinite, Timeout.Infinite);
     this.DisplayTime();
     this.UpdateRightLabel();
 }
Esempio n. 3
0
 public BasicPageWithHelp(Newhaven25664OledDriver oled) : base(oled)
 {
     this.helpPage = new BasicPage(oled);
 }
Esempio n. 4
0
 public Page(Newhaven25664OledDriver oled)
 {
     this.oled = oled;
 }
Esempio n. 5
0
 public BasicPage(Newhaven25664OledDriver oled) : base(oled)
 {
 }