I’ve been experimenting with the 4 digit display and have got it to output the current time. However, I’m having trouble getting it to show a colon. I’m likely missing something simple but I’ve been staring at the code on GitHub for far to long. How do I display the 8th bit?
# Grove 4 Digit Display - set 7 individual leds of a segment # segment: (0-3) # leds: (0-255) or (0-0xFF) one bit per led, segment 2 is special, 8th bit is the colon def fourDigit_segment(pin, segment, leds): write_i2c_block(address, fourDigitIndividualLeds_cmd + [pin, segment, leds]) time.sleep(.05) return 1
If I’m reading that right then you have 0-3 being the digits and somehow if I assign
fourDigit_segment 8 bits I should get a colon, I’m also wondering what is special about segment 2.
Here is the code I’m using for the clock:
import time from datetime import datetime import grovepi # Connect the Grove 4 Digit Display to digital port D5 # CLK,DIO,VCC,GND displayPin = 5 displayBrightness = 8 grovepi.pinMode(displayPin,"OUTPUT") while True: try: currentTime = datetime.now().strftime( "%H%M" ) #get current time timeArray = map( int,str( currentTime ) ) #map to array grovepi.fourDigit_init( displayPin ) #initalize grovepi.fourDigit_brightness( displayPin,displayBrightness ) #set brightness grovepi.fourDigit_digit( displayPin,0,timeArray ) #first digit grovepi.fourDigit_digit( displayPin,1,timeArray ) #second digit grovepi.fourDigit_digit( displayPin,2,timeArray ) #third digit grovepi.fourDigit_digit( displayPin,3,timeArray ) #fouth digit #flash on and off the colon every half second grovepi.fourDigit_segment( displayPin,4,11111111 ) time.sleep(.5) grovepi.fourDigit_segment ( displayPin,4,00000000 ) time.sleep(.5) except KeyboardInterrupt: grovepi.fourDigit_off( displayPin ) break except IOError: print ("Error")
I know the problem is with the segment code just not sure where to go to fix it. Any help would be much appreciated.