2015-10-02 17:31:43 +03:00
|
|
|
/*
|
|
|
|
|
* Author: Stefan Andritoiu <stefan.andritoiu@intel.com>
|
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-10-02 17:31:43 +03:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-10-02 17:31:43 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
//NOT TESTED!!!
|
2018-02-27 12:12:09 -08:00
|
|
|
public class TM1637_Example {
|
2015-10-02 17:31:43 +03:00
|
|
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
2015-10-08 14:30:12 +03:00
|
|
|
// ! [Interesting]
|
2015-10-02 17:31:43 +03:00
|
|
|
// TM1637 on pins 0 (clk) and 1 (dio)
|
|
|
|
|
upm_tm1637.TM1637 myDisplay = new upm_tm1637.TM1637(0, 1);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-10-02 17:31:43 +03:00
|
|
|
// Start a box using 7-segment encoding
|
|
|
|
|
myDisplay.write(0x39, 0x09, 0x09);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-10-02 17:31:43 +03:00
|
|
|
// Finish box using writeAt function
|
|
|
|
|
myDisplay.writeAt(3, ']');
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-10-02 17:31:43 +03:00
|
|
|
// Wait 3 seconds
|
|
|
|
|
Thread.sleep(3000);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-10-02 17:31:43 +03:00
|
|
|
LocalDateTime now;
|
2015-10-08 14:30:12 +03:00
|
|
|
while (true) {
|
2015-10-02 17:31:43 +03:00
|
|
|
now = LocalDateTime.now();
|
|
|
|
|
int hour = now.getHour();
|
|
|
|
|
int min = now.getMinute();
|
|
|
|
|
int sec = now.getSecond();
|
2015-10-08 14:30:12 +03:00
|
|
|
|
|
|
|
|
System.out.println(hour + ":" + min + ":" + sec);
|
2015-10-02 17:31:43 +03:00
|
|
|
myDisplay.writeString(hour + ":" + min);
|
2015-10-08 14:30:12 +03:00
|
|
|
|
2015-10-02 17:31:43 +03:00
|
|
|
Thread.sleep(1000);
|
|
|
|
|
}
|
2015-10-08 14:30:12 +03:00
|
|
|
// ! [Interesting]
|
2015-10-02 17:31:43 +03:00
|
|
|
}
|
|
|
|
|
}
|