update
This commit is contained in:
parent
21a66684fb
commit
c42152355d
|
@ -563,7 +563,7 @@ void show_motor_set_speed(uint8_t motor, uint8_t speed)
|
|||
|
||||
void motor_speed_test(void)
|
||||
{
|
||||
uint8_t speed[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint8_t speed[6] = { 128, 128, 128, 128, 128, 128 };
|
||||
uint8_t step = 10;
|
||||
uint8_t motor = 0;
|
||||
|
||||
|
@ -576,7 +576,9 @@ void motor_speed_test(void)
|
|||
show_motor_set_speed(motor, speed[motor]);
|
||||
if ( button_event == U8X8_MSG_GPIO_MENU_UP )
|
||||
{
|
||||
if ( speed[motor] < 255-step )
|
||||
if ( speed[motor] < 128 && speed[motor]+step > 128 )
|
||||
speed[motor] = 128;
|
||||
else if ( speed[motor] < 255-step )
|
||||
speed[motor] += step;
|
||||
else
|
||||
speed[motor] = 255;
|
||||
|
@ -584,7 +586,9 @@ void motor_speed_test(void)
|
|||
}
|
||||
if ( button_event == U8X8_MSG_GPIO_MENU_DOWN )
|
||||
{
|
||||
if ( speed[motor] >= step )
|
||||
if ( speed[motor] > 128 && speed[motor]-step < 128 )
|
||||
speed[motor] = 128;
|
||||
else if ( speed[motor] >= step )
|
||||
speed[motor] -=step;
|
||||
else
|
||||
speed[motor] = 0;
|
||||
|
|
|
@ -445,7 +445,7 @@ void enableADC(void)
|
|||
|
||||
|
||||
/*=======================================================================*/
|
||||
/* ADC Single Conversion */
|
||||
/* ADC Single Conversion: 8 bit resolution */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -466,7 +466,7 @@ void enableADC(void)
|
|||
ch 17: vref (bandgap)
|
||||
ch18: temperature sensor
|
||||
|
||||
returns 12 bit result, right aligned
|
||||
returns 8 bit result, right aligned
|
||||
*/
|
||||
|
||||
uint8_t adc_single_conversion_channel = 5;
|
||||
|
@ -577,7 +577,7 @@ uint16_t getADC(uint8_t ch)
|
|||
|
||||
|
||||
/*=======================================================================*/
|
||||
/* ADC Multi (DMA) Conversion */
|
||||
/* ADC Multi (DMA) Conversion: 12 bit resolution */
|
||||
|
||||
uint8_t adc_multi_conversion_channel = 6;
|
||||
volatile uint8_t adc_multi_conversion_state = 0;
|
||||
|
@ -718,6 +718,7 @@ void adcExecMultiConversion(void)
|
|||
}
|
||||
|
||||
|
||||
/* 12 bit resolution */
|
||||
void scanADC(uint8_t ch, uint16_t cnt, uint16_t *buf)
|
||||
{
|
||||
while( adcStartMultiConversion(ch, cnt, buf) == 0)
|
||||
|
@ -1217,6 +1218,7 @@ void i2c_hw_init(unsigned char address)
|
|||
void i2c_init(unsigned char address)
|
||||
{
|
||||
i2c_mem_init();
|
||||
i2c_mem[0] = 0x080; /* stop */
|
||||
i2c_hw_init(address);
|
||||
}
|
||||
|
||||
|
@ -1323,6 +1325,10 @@ int main()
|
|||
|
||||
//adc_value = getADC(5);
|
||||
adc_value = adc_variable_resistor_value;
|
||||
|
||||
adc_value = i2c_mem[0];
|
||||
|
||||
|
||||
if ( adc_value >= 0x080 )
|
||||
{
|
||||
adc_value -= 0x080;
|
||||
|
|
Loading…
Reference in New Issue