Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:examples:display:segment_display [2015/11/05 11:23] heikopikneren:examples:display:segment_display [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
-~~PB~~+<pagebreak>
 ====== 7-segment LED display ====== ====== 7-segment LED display ======
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:digi]], [LIB] [[en:software:homelab:library:delay]], [LIB] [[en:software:homelab:library:module:segment_display]][PRT] [[en:examples:digi:led]]//+//Necessary knowledge:  
 +[HW] [[en:hardware:homelab:digi]],  
 +[LIB] [[en:software:homelab:library:module:segment_display]], \\ [LIB] [[en:software:homelab:library:delay]]  
 +[PRT] [[en:examples:digi:led]]//
  
 ===== Theory ===== ===== Theory =====
Line 28: Line 31:
  
 <code c> <code c>
-// Marking card. +// Marking card 
-// The bits are marking the segments. Lower ranking is A, higher ranking is DP.+// The bits are marking the segments. Lower ranking is A, higher ranking is DP
 const unsigned char __attribute__ ((weak)) segment_char_map[11] =  const unsigned char __attribute__ ((weak)) segment_char_map[11] = 
 { {
Line 45: Line 48:
 }; };
    
-// Start-up of the 7-segment indicator.+// Start-up of the 7-segment indicator
 void segment_display_init(void) void segment_display_init(void)
 { {
Line 54: Line 57:
 } }
    
-// Displaying number on the 7-segment indicator.+// Displaying number on the 7-segment indicator
 void segment_display_write(unsigned char digit) void segment_display_write(unsigned char digit)
 { {
Line 66: Line 69:
  }  }
   
- // Number as the card of the segments.+ // Number as the card of the segments
  map = segment_char_map[digit];  map = segment_char_map[digit];
    
Line 72: Line 75:
  pin_clear(segment_display_latch);  pin_clear(segment_display_latch);
    
- // Sending he bits. Higher ranking goes first.+ // Sending he bits. Higher ranking goes first
  for (i = 7; i >= 0; i--)  for (i = 7; i >= 0; i--)
  {  {
- // Setting the pin according to the value of the bit of the card.+ // Setting the pin according to the value of the bit of the card
  pin_set_to(segment_display_data_out, bit_is_set(map, i));  pin_set_to(segment_display_data_out, bit_is_set(map, i));
    
- // The clock-signal as high for a moment.+ // The clock-signal as high for a moment
  pin_set(segment_display_clock);  pin_set(segment_display_clock);
  _delay_us(1);  _delay_us(1);
    
- // The clock-signal as low.+ // The clock-signal as low
  pin_clear(segment_display_clock);  pin_clear(segment_display_clock);
  _delay_us(1);  _delay_us(1);
  }  }
    
- // Latch-signal on.+ // Latch-signal on
  pin_set(segment_display_latch);  pin_set(segment_display_latch);
 } }
Line 102: Line 105:
 #include <homelab/delay.h> #include <homelab/delay.h>
  
-// Main program.+// Main program
 int main(void) int main(void)
 { {
Line 110: Line 113:
  segment_display_init();  segment_display_init();
  
- // Endless loop.+ // Endless loop
  while (true)  while (true)
  {  {
Line 120: Line 123:
  if (counter>19) counter=0;  if (counter>19) counter=0;
  
- // Delay for 1 second.+ // Delay for 1 second
  sw_delay_ms(1000);  sw_delay_ms(1000);
  }  }
 } }
 </code> </code>
en/examples/display/segment_display.1446722618.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0