⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spokepov.lss

📁 旋转16个LED灯控制程序
💻 LSS
📖 第 1 页 / 共 4 页
字号:
      clean = 0;		// flag that we changed things
    #endif
    
    // Start TIMER1 on its merry way...
      
    TCCR1B |= _BV(CS10);		// increment at clock/1
    TIMSK |= _BV(OCIE1A);		// enable interrupt when it matches OCR1A
    
  } else {
    
    // Since we don't have a valid setting for the rotation
    // speed, set a couple of LEDs to let the human know we
    // aren't dead yet, and turn off the timer.
      
    set_all(~0x03);
      
    TCCR1B &= ~_BV(CS10);		// no incrementing = no interrupting
    
    // reset the line timers so that when we get a valid spinup,
    // they will start clocking the lines across the display
    
    line_timer = SCROLLSPEED;		// delay figure, will trigger wrap
    line_shift = 0x0f;				// subcharacter shift, will trigger wrap
    cur_line = 0xff;				// will wrap to first line
    
  }   
    
  // Whether we're displaying or not, we reset sensor_timer so we can
  // time the next revolution.
    
  sensor_timer.word = 0;

  }
  
  // Finally, reset hall_debounce so we won't execute the timer reset code
  // until the Hall Effect sensor hasn't bothered us for a reasonable while.
  
  hall_debounce = 0;
  
  // *** PORTB &= ~0x8;

}


// Initialize the IO pins on the ATMEL.

void ioinit(void) {

  // Set the data direction for the PORTD and PORTB pins; see the
  // circuit diagram for more information on this.
  
  DDRD = 0x73; // input on PD2 (button), PD3 (sensor), all other output
  DDRB = 0xDF; // input on MOSI/DI (for SPI), all others output

  // Deselect EEPROM.  Not being an EE, I'm not going to worry about
  // how the ATMEL talks to the EEPROM.  It's black magic.
  
  PORTB = _BV(SPIEE_CS);

  // Just above, we set PD2 and PD3 to input.  If we now set those
  // bits to 1, they set into pullup mode (again, not EE, claim
  // ignorance), which is essential for them to work.  We also set
  // the SENSORPOWER bit to 1, which sends out little dribbles of
  // electrons to the hall effect sensor (see circuit diagram)
  //
  // Finally, we write 0's to the FRONT and BACK pins, which control
  // which bank of 30 LEDs we are talking to.  Having both of these
  // on at the same time probably causes horrible things to happen.
  
  PORTD = (_BV(BUTTON) | _BV(SENSOR) | _BV(SENSORPOWER))  
    & ~_BV(FRONT) & ~_BV(BACK);

  // Rather than poll to see when the hall effect sensor and
  // button are pressed, we configure an interrupt handler.  If you
  // look at the circuit diagram, you'll see that PD3 and PD2, which
  // are wired to SENSOR IN and BUTTON IN, do double-duty as INT1
  // and INT0.  They are both SUPPOSEDLY set to interrupt on the
  // falling edge of a pulse from the devices.  (Page 63)
  
  // POSSIBLE BUG: ISC0{1,0} seems to be being set to 00, not 10
  // as ISC1{1,0} is being set to.  So ISC0 will trigger when
  // the button interrupt line goes low.  Either this is a bug,
  // or the original comment was not correct (likely, IMHO)
  
  MCUCR = _BV(ISC11) & ~_BV(ISC01) & ~_BV(ISC00) &  ~_BV(ISC10);

  // Activate the interrupts by setting the General Interrupt Mask
  // Register (Page 63)
  
  GIMSK = _BV(INT1) | _BV(INT0);

  // The ATMEL has built-in timers that can trigger an interrupt.
  // SpokePOV uses them to update the LEDs 256 times per rotation.
  
  // Timer 0 is set to update at a rate system-clock / 256 and
  // interrupt when it overflows (8 bit).  This means that it
  // triggers every 65536 cycles.
  
  TCCR0A = 0;				// normal, overflow (count up to 256 == num pixels)
  TCCR0B = _BV(CS02);		// clk/256
  TIMSK |= _BV(TOIE0);		// turn on overflow interrupt
  
  // Timer 1 (T1) is the pixel timer, which is used to update the
  // LEDs 256 times per rotation.  It's set up as a normal timer
  // as well.  See Page 108&71; it is apparently being set into CTC
  // mode 4.  This means that the counter is compared to a 16-bit value
  // and interrupts when it reaches this value.
  //
  // Adjusting this value is how the SpokePOV compensates for
  // changes in the rotation speed of the device.
  //
  // Note that at this point, the timer is initialized, but not
  // activated.
  
  TCCR1A = 0;
  TCCR1B = _BV(WGM12);

  // Clear the debounce values, which I haven't sussed out yet.
  
  hall_debounce = 0;
  sensor_timer.word = 0;
  
}

// Turn on a single LED, turning off all the other LEDs

//void set_led(uint8_t led) {

//  fleds[0] = fleds[1] = fleds[2] = fleds[3] = 0xFF;
//  fleds[led >> 3] = ~_BV(led & 0x7F);

//  clock_scroll(0);
//}

// Set all the LEDs on a side to have the same
// repeating 8-bit value (ie: 0x00 = all on, 0xFF = all off)
// Added by RJW to permit a more comprehensive reset display

void set_all(uint8_t blockValue) {

  fleds[0] = fleds[1] = fleds[2] = fleds[3] = blockValue;
 13a:	80 93 82 00 	sts	0x0082, r24
 13e:	80 93 81 00 	sts	0x0081, r24
 142:	80 93 80 00 	sts	0x0080, r24
 146:	80 93 7f 00 	sts	0x007F, r24
  
  clock_scroll(0);
 14a:	80 e0       	ldi	r24, 0x00	; 0
 14c:	aa df       	rcall	.-172    	; 0xa2 <clock_scroll>
 14e:	08 95       	ret

00000150 <__vector_4>:
 150:	1f 92       	push	r1
 152:	0f 92       	push	r0
 154:	0f b6       	in	r0, 0x3f	; 63
 156:	0f 92       	push	r0
 158:	11 24       	eor	r1, r1
 15a:	2f 93       	push	r18
 15c:	3f 93       	push	r19
 15e:	4f 93       	push	r20
 160:	5f 93       	push	r21
 162:	6f 93       	push	r22
 164:	7f 93       	push	r23
 166:	8f 93       	push	r24
 168:	9f 93       	push	r25
 16a:	af 93       	push	r26
 16c:	bf 93       	push	r27
 16e:	ef 93       	push	r30
 170:	ff 93       	push	r31
 172:	80 91 7e 00 	lds	r24, 0x007E
 176:	82 30       	cpi	r24, 0x02	; 2
 178:	08 f0       	brcs	.+2      	; 0x17c <__vector_4+0x2c>
 17a:	7e c0       	rjmp	.+252    	; 0x278 <__vector_4+0x128>
 17c:	80 91 66 00 	lds	r24, 0x0066
 180:	8f 5f       	subi	r24, 0xFF	; 255
 182:	80 93 66 00 	sts	0x0066, r24
 186:	80 91 66 00 	lds	r24, 0x0066
 18a:	80 31       	cpi	r24, 0x10	; 16
 18c:	d9 f5       	brne	.+118    	; 0x204 <__vector_4+0xb4>
 18e:	80 91 67 00 	lds	r24, 0x0067
 192:	8f 30       	cpi	r24, 0x0F	; 15
 194:	29 f4       	brne	.+10     	; 0x1a0 <__vector_4+0x50>
 196:	8e b5       	in	r24, 0x2e	; 46
 198:	88 7f       	andi	r24, 0xF8	; 248
 19a:	8e bd       	out	0x2e, r24	; 46
 19c:	8f ef       	ldi	r24, 0xFF	; 255
 19e:	70 c0       	rjmp	.+224    	; 0x280 <__vector_4+0x130>
 1a0:	10 92 66 00 	sts	0x0066, r1
 1a4:	80 91 67 00 	lds	r24, 0x0067
 1a8:	8f 5f       	subi	r24, 0xFF	; 255
 1aa:	8f 70       	andi	r24, 0x0F	; 15
 1ac:	80 93 67 00 	sts	0x0067, r24
 1b0:	80 91 67 00 	lds	r24, 0x0067
 1b4:	e8 2f       	mov	r30, r24
 1b6:	ff 27       	eor	r31, r31
 1b8:	eb 57       	subi	r30, 0x7B	; 123
 1ba:	ff 4f       	sbci	r31, 0xFF	; 255
 1bc:	80 81       	ld	r24, Z
 1be:	99 27       	eor	r25, r25
 1c0:	80 97       	sbiw	r24, 0x20	; 32
 1c2:	88 0f       	add	r24, r24
 1c4:	99 1f       	adc	r25, r25
 1c6:	90 93 6b 00 	sts	0x006B, r25
 1ca:	80 93 6a 00 	sts	0x006A, r24
 1ce:	80 91 67 00 	lds	r24, 0x0067
 1d2:	e8 2f       	mov	r30, r24
 1d4:	ff 27       	eor	r31, r31
 1d6:	eb 56       	subi	r30, 0x6B	; 107
 1d8:	ff 4f       	sbci	r31, 0xFF	; 255
 1da:	80 81       	ld	r24, Z
 1dc:	99 27       	eor	r25, r25
 1de:	80 97       	sbiw	r24, 0x20	; 32
 1e0:	88 0f       	add	r24, r24
 1e2:	99 1f       	adc	r25, r25
 1e4:	90 93 69 00 	sts	0x0069, r25
 1e8:	80 93 68 00 	sts	0x0068, r24
 1ec:	80 91 67 00 	lds	r24, 0x0067
 1f0:	e8 2f       	mov	r30, r24
 1f2:	ff 27       	eor	r31, r31
 1f4:	e4 59       	subi	r30, 0x94	; 148
 1f6:	ff 4f       	sbci	r31, 0xFF	; 255
 1f8:	80 81       	ld	r24, Z
 1fa:	99 27       	eor	r25, r25
 1fc:	80 97       	sbiw	r24, 0x20	; 32
 1fe:	88 0f       	add	r24, r24
 200:	99 1f       	adc	r25, r25
 202:	1a c0       	rjmp	.+52     	; 0x238 <__vector_4+0xe8>
 204:	80 91 6a 00 	lds	r24, 0x006A
 208:	90 91 6b 00 	lds	r25, 0x006B
 20c:	80 54       	subi	r24, 0x40	; 64
 20e:	9f 4f       	sbci	r25, 0xFF	; 255
 210:	90 93 6b 00 	sts	0x006B, r25
 214:	80 93 6a 00 	sts	0x006A, r24
 218:	80 91 68 00 	lds	r24, 0x0068
 21c:	90 91 69 00 	lds	r25, 0x0069
 220:	80 54       	subi	r24, 0x40	; 64
 222:	9f 4f       	sbci	r25, 0xFF	; 255
 224:	90 93 69 00 	sts	0x0069, r25
 228:	80 93 68 00 	sts	0x0068, r24
 22c:	80 91 64 00 	lds	r24, 0x0064
 230:	90 91 65 00 	lds	r25, 0x0065
 234:	80 54       	subi	r24, 0x40	; 64
 236:	9f 4f       	sbci	r25, 0xFF	; 255
 238:	90 93 65 00 	sts	0x0065, r25
 23c:	80 93 64 00 	sts	0x0064, r24
 240:	42 e0       	ldi	r20, 0x02	; 2
 242:	6f e7       	ldi	r22, 0x7F	; 127
 244:	70 e0       	ldi	r23, 0x00	; 0
 246:	80 91 6a 00 	lds	r24, 0x006A
 24a:	90 91 6b 00 	lds	r25, 0x006B
 24e:	4a d1       	rcall	.+660    	; 0x4e4 <spieeprom_read>
 250:	42 e0       	ldi	r20, 0x02	; 2
 252:	61 e8       	ldi	r22, 0x81	; 129
 254:	70 e0       	ldi	r23, 0x00	; 0
 256:	80 91 68 00 	lds	r24, 0x0068
 25a:	90 91 69 00 	lds	r25, 0x0069
 25e:	42 d1       	rcall	.+644    	; 0x4e4 <spieeprom_read>
 260:	42 e0       	ldi	r20, 0x02	; 2
 262:	63 e8       	ldi	r22, 0x83	; 131
 264:	70 e0       	ldi	r23, 0x00	; 0
 266:	80 91 64 00 	lds	r24, 0x0064
 26a:	90 91 65 00 	lds	r25, 0x0065
 26e:	3a d1       	rcall	.+628    	; 0x4e4 <spieeprom_read>
 270:	80 91 60 00 	lds	r24, 0x0060
 274:	16 df       	rcall	.-468    	; 0xa2 <clock_scroll>
 276:	05 c0       	rjmp	.+10     	; 0x282 <__vector_4+0x132>
 278:	8e b5       	in	r24, 0x2e	; 46
 27a:	88 7f       	andi	r24, 0xF8	; 248
 27c:	8e bd       	out	0x2e, r24	; 46
 27e:	88 ef       	ldi	r24, 0xF8	; 248
 280:	5c df       	rcall	.-328    	; 0x13a <set_all>
 282:	ff 91       	pop	r31
 284:	ef 91       	pop	r30
 286:	bf 91       	pop	r27
 288:	af 91       	pop	r26
 28a:	9f 91       	pop	r25
 28c:	8f 91       	pop	r24
 28e:	7f 91       	pop	r23
 290:	6f 91       	pop	r22
 292:	5f 91       	pop	r21
 294:	4f 91       	pop	r20
 296:	3f 91       	pop	r19
 298:	2f 91       	pop	r18
 29a:	0f 90       	pop	r0
 29c:	0f be       	out	0x3f, r0	; 63
 29e:	0f 90       	pop	r0
 2a0:	1f 90       	pop	r1
 2a2:	18 95       	reti

000002a4 <__vector_1>:
 2a4:	1f 92       	push	r1
 2a6:	0f 92       	push	r0
 2a8:	0f b6       	in	r0, 0x3f	; 63
 2aa:	0f 92       	push	r0
 2ac:	11 24       	eor	r1, r1
 2ae:	8f 93       	push	r24
 2b0:	82 9b       	sbis	0x10, 2	; 16
 2b2:	fe cf       	rjmp	.-4      	; 0x2b0 <__vector_1+0xc>
 2b4:	80 91 7e 00 	lds	r24, 0x007E
 2b8:	8f 3f       	cpi	r24, 0xFF	; 255
 2ba:	29 f4       	brne	.+10     	; 0x2c6 <__vector_1+0x22>
 2bc:	10 92 7e 00 	sts	0x007E, r1
 2c0:	88 e0       	ldi	r24, 0x08	; 8
 2c2:	81 bd       	out	0x21, r24	; 33
 2c4:	ff cf       	rjmp	.-2      	; 0x2c4 <__vector_1+0x20>
 2c6:	8f ef       	ldi	r24, 0xFF	; 255
 2c8:	80 93 7e 00 	sts	0x007E, r24
 2cc:	8f 91       	pop	r24
 2ce:	0f 90       	pop	r0
 2d0:	0f be       	out	0x3f, r0	; 63
 2d2:	0f 90       	pop	r0
 2d4:	1f 90       	pop	r1
 2d6:	18 95       	reti

000002d8 <__vector_2>:
 2d8:	1f 92       	push	r1
 2da:	0f 92       	push	r0
 2dc:	0f b6       	in	r0, 0x3f	; 63
 2de:	0f 92       	push	r0
 2e0:	11 24       	eor	r1, r1
 2e2:	1f 93       	push	r17
 2e4:	2f 93       	push	r18
 2e6:	3f 93       	push	r19
 2e8:	4f 93       	push	r20
 2ea:	5f 93       	push	r21
 2ec:	6f 93       	push	r22
 2ee:	7f 93       	push	r23
 2f0:	8f 93       	push	r24
 2f2:	9f 93       	push	r25
 2f4:	af 93       	push	r26
 2f6:	bf 93       	push	r27
 2f8:	ef 93       	push	r30
 2fa:	ff 93       	push	r31
 2fc:	a8 95       	wdr
 2fe:	80 91 7c 00 	lds	r24, 0x007C
 302:	85 30       	cpi	r24, 0x05	; 5
 304:	08 f4       	brcc	.+2      	; 0x308 <__vector_2+0x30>
 306:	86 c0       	rjmp	.+268    	; 0x414 <__vector_2+0x13c>
 308:	1d bc       	out	0x2d, r1	; 45
 30a:	1c bc       	out	0x2c, r1	; 44
 30c:	80 91 7e 00 	lds	r24, 0x007E
 310:	88 23       	and	r24, r24
 312:	29 f0       	breq	.+10     	; 0x31e <__vector_2+0x46>
 314:	80 91 7d 00 	lds	r24, 0x007D
 318:	84 30       	cpi	r24, 0x04	; 4
 31a:	08 f4       	brcc	.+2      	; 0x31e <__vector_2+0x46>
 31c:	69 c0       	rjmp	.+210    	; 0x3f0 <__vector_2+0x118>
 31e:	80 91 7d 00 	lds	r24, 0x007D
 322:	8b bd       	out	0x2b, r24	; 43
 324:	82 b7       	in	r24, 0x32	; 50
 326:	8a bd       	out	0x2a, r24	; 42
 328:	12 be       	out	0x32, r1	; 50
 32a:	80 91 62 00 	lds	r24, 0x0062
 32e:	80 31       	cpi	r24, 0x10	; 16
 330:	08 f4       	brcc	.+2      	; 0x334 <__vector_2+0x5c>
 332:	51 c0       	rjmp	.+162    	; 0x3d6 <__vector_2+0xfe>
 334:	80 91 62 00 	lds	r24, 0x0062
 338:	80 51       	subi	r24, 0x10	; 16
 33a:	80 93 62 00 	sts	0x0062, r24
 33e:	80 91 60 00 	lds	r24, 0x0060
 342:	8f 5f       	subi	r24, 0xFF	; 255
 344:	8f 70       	andi	r24, 0x0F	; 15
 346:	80 93 60 00 	sts	0x0060, r24
 34a:	90 91 60 00 	lds	r25, 0x0060
 34e:	99 23       	and	r25, r25
 350:	09 f0       	breq	.+2      	; 0x354 <__vector_2+0x7c>
 352:	41 c0       	rjmp	.+130    	; 0x3d6 <__vector_2+0xfe>
 354:	80 91 61 00 	lds	r24, 0x0061
 358:	8f 5f       	subi	r24, 0xFF	; 255
 35a:	80 93 61 00 	sts	0x0061, r24
 35e:	80 91 61 00 	lds	r24, 0x0061
 362:	85 30       	cpi	r24, 0x05	; 5
 364:	11 f4       	brne	.+4      	; 0x36a <__vector_2+0x92>
 366:	90 93 61 00 	sts	0x0061, r25
 36a:	80 91 61 00 	lds	r24, 0x0061
 36e:	e8 2f       	mov	r30, r24
 370:	ff 27       	eor	r31, r31
 372:	e9 59       	subi	r30, 0x99	; 153
 374:	ff 4f       	sbci	r31, 0xFF	; 255
 376:	c8 95       	lpm
 378:	80 2d       	mov	r24, r0
 37a:	99 27       	eor	r25, r25
 37c:	8a 5d       	subi	r24, 0xDA	; 218
 37e:	9f 4f       	sbci	r25, 0xFF	; 255
 380:	40 e1       	ldi	r20, 0x10	; 16
 382:	50 e0       	ldi	r21, 0x00	; 0
 384:	68 2f       	mov	r22, r24
 386:	79 2f       	mov	r23, r25
 388:	85 e8       	ldi	r24, 0x85	; 133
 38a:	90 e0       	ldi	r25, 0x00	; 0
 38c:	d1 d0       	rcall	.+418    	; 0x530 <memcpy_P>
 38e:	10 91 61 00 	lds	r17, 0x0061
 392:	1f 5f       	subi	r17, 0xFF	; 255
 394:	e1 2f       	mov	r30, r17
 396:	ff 27       	eor	r31, r31
 398:	e9 59       	subi	r30, 0x99	; 153
 39a:	ff 4f       	sbci	r31, 0xFF	; 255
 39c:	c8 95       	lpm
 39e:	80 2d       	mov	r24, r0
 3a0:	99 27       	eor	r25, r25
 3a2:	8a 5d       	subi	r24, 0xDA	; 218
 3a4:	9f 4f       	sbci	r25, 0xFF	; 255
 3a6:	40 e1       	ldi	r20, 0x10	; 16
 3a8:	50 e0       	ldi	r21, 0x00	; 0
 3aa:	68 2f       	mov	r22, r24
 3ac:	79 2f       	mov	r23, r25
 3ae:	85 e9       	ldi	r24, 0x95	; 149
 3b0:	90 e0       	ldi	r25, 0x00	; 0
 3b2:	be d0       	rcall	.+380    	; 0x530 <memcpy_P>
 3b4:	1f 5f       	subi	r17, 0xFF	; 255
 3b6:	e1 2f       	mov	r30, r17
 3b8:	ff 27       	eor	r31, r31
 3ba:	e9 59       	subi	r30, 0x99	; 153
 3bc:	ff 4f       	sbci	r31, 0xFF	; 255
 3be:	c8 95       	lpm
 3c0:	80 2d       	mov	r24, r0
 3c2:	99 27       	eor	r25, r25
 3c4:	8a 5d       	subi	r24, 0xDA	; 218
 3c6:	9f 4f       	sbci	r25, 0xFF	; 255
 3c8:	40 e1       	ldi	r20, 0x10	; 16
 3ca:	50 e0       	ldi	r21, 0x00	; 0
 3cc:	68 2f       	mov	r22, r24
 3ce:	79 2f       	mov	r23, r25
 3d0:	8c e6       	ldi	r24, 0x6C	; 108
 3d2:	90 e0       	ldi	r25, 0x00	; 0
 3d4:	ad d0       	rcall	.+346    	; 0x530 <memcpy_P>
 3d6:	8f e1       	ldi	r24, 0x1F	; 31
 3d8:	80 93 67 00 	sts	0x0067, r24
 3dc:	8f e0       	ldi	r24, 0x0F	; 15
 3de:	80 93 66 00 	sts	0x0066, r24
 3e2:	8e b5       	in	r24, 0x2e	; 46
 3e4:	81 60       	ori	r24, 0x01	; 1
 3e6:	8e bd       	out	0x2e, r24	; 46
 3e8:	89 b7       	in	r24, 0x39	; 57
 3ea:	80 64       	ori	r24, 0x40	; 64
 3ec:	89 bf       	out	0x39, r24	; 57
 3ee:	0e c0       	rjmp	.+28     	; 0x40c <__vector_2+0x134>
 3f0:	8c ef       	ldi	r24, 0xFC	; 252
 3f2:	a3 de       	rcall	.-698    	; 0x13a <set_all>
 3f4:	8e b5       	in	r24, 0x2e	; 46
 3f6:	8e 7f       	andi	r24, 0xFE	; 254
 3f8:	8e bd       	out	0x2e, r24	; 46
 3fa:	80 e1       	ldi	r24, 0x10	; 16
 3fc:	80 93 62 00 	sts	0x0062, r24
 400:	8f e0       	ldi	r24, 0x0F	; 15
 402:	80 93 60 00 	sts	0x0060, r24
 406:	8f ef       	ldi	r24, 0xFF	; 255
 408:	80 93 61 00 	sts	0x0061, r24
 40c:	10 92 7e 00 	sts	0x007E, r1
 410:	10 92 7d 00 	sts	0x007D, r1
 414:	10 92 7c 00 	sts	0x007C, r1
 418:	ff 91       	pop	r31
 41a:	ef 91       	pop	r30
 41c:	bf 91       	pop	r27
 41e:	af 91       	pop	r26
 420:	9f 91       	pop	r25
 422:	8f 91       	pop	r24
 424:	7f 91       	pop	r23
 426:	6f 91       	pop	r22
 428:	5f 91       	pop	r21
 42a:	4f 91       	pop	r20
 42c:	3f 91       	pop	r19
 42e:	2f 91       	pop	r18
 430:	1f 91       	pop	r17
 432:	0f 90       	pop	r0
 434:	0f be       	out	0x3f, r0	; 63
 436:	0f 90       	pop	r0
 438:	1f 90       	pop	r1
 43a:	18 95       	reti

0000043c <ioinit>:
 43c:	83 e7       	ldi	r24, 0x73	; 115

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -