@@ -690,13 +690,14 @@ func (s *SenseHat) SetPixel(x, y int, r, g, b uint8) error {
690690 if err := setI2CAddr (s .i2cFile , addrLEDMatrix ); err != nil {
691691 return err
692692 }
693- // Each pixel is 3 bytes (RGB), scaled from 0-255 to 0-31
694- offset := (y * 8 + x ) * 3
693+ // Each pixel is 3 bytes (RBG order for ATTINY88), scaled from 0-255 to 0-31
694+ // The LED matrix is laid out with x as rows (closest to GPIO = x=0)
695+ offset := (x * 8 + y ) * 3
695696 buf := []byte {
696697 byte (offset ),
697698 r >> 3 ,
698- g >> 3 ,
699699 b >> 3 ,
700+ g >> 3 ,
700701 }
701702 _ , err := s .i2cFile .Write (buf )
702703 return err
@@ -712,29 +713,35 @@ func (s *SenseHat) FlashLED(x, y int, r, g, b uint8, duration time.Duration) err
712713 return s .SetPixel (x , y , 0 , 0 , 0 )
713714}
714715
715- // SetNavLights turns on the navigation lights (red port, green starboard) on the bottom row.
716+ // SetNavLights turns on the navigation lights (red port, green starboard) on the top row.
716717func (s * SenseHat ) SetNavLights () error {
717- if err := s .SetPixel (0 , 7 , 255 , 0 , 0 ); err != nil { // Red - port (left)
718+ if err := s .SetPixel (0 , 0 , 255 , 0 , 0 ); err != nil { // Red - port (left)
718719 return err
719720 }
720- return s .SetPixel (7 , 7 , 0 , 255 , 0 ) // Green - starboard (right)
721+ return s .SetPixel (7 , 0 , 0 , 255 , 0 ) // Green - starboard (right)
721722}
722723
723- // FlashStrobes briefly flashes the strobe lights on the top corners.
724+ // FlashStrobes double- flashes the strobe lights on the bottom corners (0,7) and (7,7) .
724725func (s * SenseHat ) FlashStrobes (duration time.Duration ) error {
725- // Turn on strobes
726- if err := s .SetPixel (0 , 0 , 255 , 255 , 255 ); err != nil {
727- return err
728- }
729- if err := s .SetPixel (7 , 0 , 255 , 255 , 255 ); err != nil {
730- return err
731- }
732- time .Sleep (duration )
733- // Turn off strobes
734- if err := s .SetPixel (0 , 0 , 0 , 0 , 0 ); err != nil {
735- return err
726+ // Double flash pattern
727+ for flash := 0 ; flash < 2 ; flash ++ {
728+ // Flash on - bottom left corner
729+ s .SetPixel (0 , 7 , 255 , 255 , 255 )
730+ // Flash on - bottom right corner
731+ s .SetPixel (7 , 7 , 255 , 255 , 255 )
732+
733+ time .Sleep (duration )
734+
735+ // Flash off - bottom left corner
736+ s .SetPixel (0 , 7 , 0 , 0 , 0 )
737+ // Flash off - bottom right corner
738+ s .SetPixel (7 , 7 , 0 , 0 , 0 )
739+
740+ if flash == 0 {
741+ time .Sleep (duration / 2 )
742+ }
736743 }
737- return s . SetPixel ( 7 , 0 , 0 , 0 , 0 )
744+ return nil
738745}
739746
740747// PlaneAnimation animates a plane flying across the LED matrix with nav lights.
@@ -768,21 +775,21 @@ func (s *SenseHat) PlaneAnimation(frameDelay time.Duration) error {
768775 }
769776 }
770777
771- // Navigation lights: green on right (starboard ), red on left (port)
772- if err := s .SetPixel (0 , 7 , 255 , 0 , 0 ); err != nil { // Red - port (left)
778+ // Navigation lights: red on left (port ), green on right (starboard) - top row
779+ if err := s .SetPixel (0 , 0 , 255 , 0 , 0 ); err != nil { // Red - port (left)
773780 return err
774781 }
775- if err := s .SetPixel (7 , 7 , 0 , 255 , 0 ); err != nil { // Green - starboard (right)
782+ if err := s .SetPixel (7 , 0 , 0 , 255 , 0 ); err != nil { // Green - starboard (right)
776783 return err
777784 }
778785
779- // Strobe lights: white flashing every 4 frames, opposite corners
786+ // Strobe lights: white double- flashing every 4 frames - bottom corners
780787 strobeOn := (strobeCounter % 4 ) < 2
781788 if strobeOn {
782- if err := s .SetPixel (7 , 0 , 255 , 255 , 255 ); err != nil { // White strobe top-right
789+ if err := s .SetPixel (0 , 7 , 255 , 255 , 255 ); err != nil { // White strobe bottom-left
783790 return err
784791 }
785- if err := s .SetPixel (0 , 0 , 255 , 255 , 255 ); err != nil { // White strobe top-left
792+ if err := s .SetPixel (7 , 7 , 255 , 255 , 255 ); err != nil { // White strobe bottom-right
786793 return err
787794 }
788795 }
0 commit comments