public static async Task Aggregator( FPGA.OutputSignal <bool> Bank2, FPGA.OutputSignal <bool> SEG_A, FPGA.OutputSignal <bool> SEG_B, FPGA.OutputSignal <bool> SEG_C, FPGA.OutputSignal <bool> SEG_D, FPGA.OutputSignal <bool> SEG_E, FPGA.OutputSignal <bool> SEG_F, FPGA.OutputSignal <bool> SEG_G, FPGA.OutputSignal <bool> SEG_P) { QuokkaBoard.OutputBank(Bank2); byte counter = 0; byte segmentValue = 0; SevenSegment.LinkLEDs( segmentValue, SEG_A, SEG_B, SEG_C, SEG_D, SEG_E, SEG_F, SEG_G, SEG_P); BlastOff(out segmentValue); }
public lcdControler(SevenSegment sevenSegment1, SevenSegment sevenSegment2, SevenSegment sevenSegment3, SevenSegment sevenSegment4) { this.sevenSegment1 = sevenSegment1; this.sevenSegment2 = sevenSegment2; this.sevenSegment3 = sevenSegment3; this.sevenSegment4 = sevenSegment4; }
private void Init(SevenSegment[] arr) { for (int i = 0; i < 4; i++) { arr[i] = new SevenSegment(); arr[i].ColorBackground = Color.Black; arr[i].ColorDark = Color.Black; arr[i].ColorLight = Color.Red; arr[i].Padding = new System.Windows.Forms.Padding(2, 0, 2, 0); } }
public SevenSegmentApp() { sevenSegment = new SevenSegment ( portA: Device.CreateDigitalOutputPort(Device.Pins.D01), portB: Device.CreateDigitalOutputPort(Device.Pins.D00), portC: Device.CreateDigitalOutputPort(Device.Pins.D08), portD: Device.CreateDigitalOutputPort(Device.Pins.D07), portE: Device.CreateDigitalOutputPort(Device.Pins.D06), portF: Device.CreateDigitalOutputPort(Device.Pins.D11), portG: Device.CreateDigitalOutputPort(Device.Pins.D09), portDecimal: Device.CreateDigitalOutputPort(Device.Pins.D10), isCommonCathode: false ); TestSevenSegment(); }
public static void Main() { // Initializes a 7-segment display over a bitshift IC using a single IC Ic74hc595 Mux = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D10); SevenSegment Display = new SevenSegment(Mux.CreateParallelOut()); while (true) { for (byte Value = 0; Value < 11; ++Value) { // Displays all values for 0,5 sec. (0-9 = 0-9, 10=blank) Display.SetDigit(Value); // Toggles the dot Display.SetDot(!Display.GetDot()); // Wait for 0,5 sec Thread.Sleep(500); } } }
public MeadowApp() { Console.WriteLine("Initializing..."); sevenSegment = new SevenSegment ( portA: Device.CreateDigitalOutputPort(Device.Pins.D01), portB: Device.CreateDigitalOutputPort(Device.Pins.D00), portC: Device.CreateDigitalOutputPort(Device.Pins.D08), portD: Device.CreateDigitalOutputPort(Device.Pins.D07), portE: Device.CreateDigitalOutputPort(Device.Pins.D06), portF: Device.CreateDigitalOutputPort(Device.Pins.D11), portG: Device.CreateDigitalOutputPort(Device.Pins.D09), portDecimal: Device.CreateDigitalOutputPort(Device.Pins.D10), isCommonCathode: false ); TestSevenSegment(); }
/// <summary> /// Change the number of elements in our LED array. This destroys /// the previous elements, and creates new ones in their place, applying /// all the current options to the new ones. /// </summary> /// <param name="count">Number of elements to create.</param> public void RecreateSegments(int count) { if (segments != null) for (int i = 0; i < segments.Length; i++) { segments[i].Parent = null; segments[i].Dispose(); } if (count <= 0) return; segments = new SevenSegment[count]; for (int i = 0; i < count; i++) { segments[i] = new SevenSegment(); segments[i].Parent = this; segments[i].Top = 0; segments[i].gridHeight = this.Height - elementPadding.Vertical; segments[i].Height = this.Height; segments[i].Anchor = AnchorStyles.Top | AnchorStyles.Bottom; segments[i].Visible = true; } ResizeSegments(true); UpdateSegments(); this.Value = theValue; }
public static void Main() { // Outputs: // - Buzzer (GPIO D3) // - Segment7 (7-Segment display/74HC595 IC) (SPI D4, D7, D8) // - Led1 (PWM D5) // - Led2 (PWM D6) #region "Output definitions" // The buzzer is connected directly to GPIO pin D3 BitBangBuzzer Buzzer = new BitBangBuzzer(Pins.GPIO_PIN_D3); // The 7-segment display is connected with a 74HC595 bitshift IC over GPIO pins D4 (MOSI), D7 (CS) and D8 (SCLK) Ic74hc595 Mux = new Ic74hc595(Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D7); SevenSegment Segment7 = new SevenSegment(Mux.CreateParallelOut()); // The DangerShield has the digits defined differently; these bits are used: // Top = 1 // UpperRight = 2 // LowerRight = 3 // Bottom = 4 // LowerLeft = 5 // UpperLeft = 6 // Middle = 7 // Dot = 8 Segment7.ChangeSignals(new byte[] { // (87654321) 0x3f, // 0 brights up: 0 1 2 3 4 5 (00111111) 0x06, // 1 brights up: 1 2 (00000110) 0x5b, // 2 brights up: 0 1 3 4 6 (01011011) 0x4f, // 3 brights up: 0 1 2 3 6 (01001111) 0x66, // 4 brights up: 1 2 5 6 (01100110) 0x6d, // 5 brights up: 0 2 3 5 6 (01101101) 0x7d, // 6 brights up: 0 2 3 4 5 6 (01111101) 0x07, // 7 brights up: 0 1 2 (00000111) 0x7f, // 8 brights up: 0 1 2 3 4 5 6 (01111111) 0x6f, // 9 brights up: 0 1 2 3 5 6 (01101111) 0x00, // all go down: 0 1 2 4 5 6 7 (00000000) }); Segment7.ChangeDotSignal(8); // Both leds IPWMPort Led1 = new Netduino.PWM(Pins.GPIO_PIN_D5); Led1.StartPulse(); IPWMPort Led2 = new Netduino.PWM(Pins.GPIO_PIN_D6); Led2.StartPulse(); #endregion // Inputs: // - PotentioMeter1 (ADC A0) // - PotentioMeter2 (ADC A1) // - PotentioMeter3 (ADC A2) // - Photocell (ADC A3) // - TemperatureSensor (ADC A4) // - KnockSensor (ADC A5) // - PushButton1 (GPIO D10) // - PushButton2 (GPIO D11) // - PushButton3 (GPIO D12) #region "Input definitions" // Potentio meters IADCPort PotentioMeter1 = new Netduino.ADC(Pins.GPIO_PIN_A0); PotentioMeter1.RangeSet(0, 100); // Same range as Led1.SetDutyCycle() IADCPort PotentioMeter2 = new Netduino.ADC(Pins.GPIO_PIN_A1); PotentioMeter2.RangeSet(0, 100); // Same range as Led2.SetDutyCycle() IADCPort PotentioMeter3 = new Netduino.ADC(Pins.GPIO_PIN_A2); PotentioMeter3.RangeSet(0, 9); // Same range as Segment7.SetDigit() // Photocell IADCPort Photocell = new Netduino.ADC(Pins.GPIO_PIN_A3); Photocell.RangeSet(0, 100); // Same range as Led2.SetDutyCycle() // Temperature Sensor Tmp36 TemperatureSensor = new Tmp36(new Netduino.ADC(Pins.GPIO_PIN_A4)); // Knock Sensor IADCPort KnockSensor = new Netduino.ADC(Pins.GPIO_PIN_A5); KnockSensor.RangeSet(0, 200); // Bigger range as Led1.SetDutyCycle() but you really need to smash hard to reach this value // Push buttons InputPort PushButton1 = new InputPort(Pins.GPIO_PIN_D10, false, Port.ResistorMode.Disabled); InputPort PushButton2 = new InputPort(Pins.GPIO_PIN_D11, false, Port.ResistorMode.Disabled); InputPort PushButton3 = new InputPort(Pins.GPIO_PIN_D12, false, Port.ResistorMode.Disabled); #endregion // This value contains which demo is currently active int Demo = 1; // Contains the last second, so we can switch between two numbers on the 7-segment display (to display the temperature) int LastSecond = Utility.GetMachineTime().Seconds; // This digit should be currently shown bool ShowSecondDigit = false; // Infinite loop while (true) { // Switches the demo, when required (NOT statement because of the pullup resistors) if (!PushButton1.Read()) { Demo = 1; } if (!PushButton2.Read()) { Demo = 2; } if (Demo == 1) { // First demo is currently active Led1.SetDutyCycle((uint)PotentioMeter1.RangeRead()); Led2.SetDutyCycle((uint)PotentioMeter2.RangeRead()); Segment7.SetDigit((byte)PotentioMeter3.RangeRead()); } else { // Second demo is currently active uint Knocking = (uint)KnockSensor.RangeRead(); Led1.SetDutyCycle((uint)(Knocking > 100 ? 100 : Knocking)); // We want to limit to 100 Led1.SetDutyCycle((uint)KnockSensor.RangeRead()); Led2.SetDutyCycle((uint)Photocell.RangeRead()); // Okay, we want two temperature digits seprated, for display purposes float Temp = TemperatureSensor.Temperature; byte Digit1 = (byte)(Temp / 10); byte Digit0 = (byte)(Temp - (10 * Digit1)); // Switch the digit to be displayed if (LastSecond != Utility.GetMachineTime().Seconds) { LastSecond = Utility.GetMachineTime().Seconds; Segment7.SetDigit(ShowSecondDigit ? Digit1 : Digit0); Segment7.SetDot(!ShowSecondDigit); ShowSecondDigit = !ShowSecondDigit; } } // Links the buzzer to the 3rd pushbutton's value Buzzer.Write(!PushButton3.Read()); } }
// Use this for initialization void Start() { SevenSegmentDisplay = gameObject.GetComponent <SevenSegment>(); }
/// <summary> /// Change the number of elements in our LED array. This destroys /// the previous elements, and creates new ones in their place, applying /// all the current options to the new ones. /// </summary> /// <param name="count">Number of elements to create.</param> public void RecreateSegments(int count) { if (segments != null) for (int i = 0; i < segments.Length; i++) { segments[i].Parent = null; segments[i].Dispose(); } if (count <= 0) return; segments = new SevenSegment[count]; for (int i = 0; i < count; i++) { segments[i] = new SevenSegment(); segments[i].Parent = this; segments[i].Top = 0; segments[i].gridHeight = this.Height - elementPadding.Vertical; segments[i].Height = this.Height; segments[i].Anchor = AnchorStyles.Top | AnchorStyles.Bottom; segments[i].Visible = true; if (this.Name == "led_ohm") { /* segments[i].Click += new EventHandler((o, e) => { Mndz.Form1 f1 = Program.mainwnd; f1.Invoke(new Action<object, object>(f1.led_ohm_Click), new object[] { o, e }); }); */ } } ResizeSegments(true); UpdateSegments(); this.Value = theValue; }