示例#1
0
文件: elev.c 项目: jhosen/elevator
void elev_set_speed(int speed)
{
	// In order to sharply stop the elevator, the direction bit is toggled
	// before setting speed to zero.
	static int last_speed = 0;
	
	// If to start (speed > 0)
	if (speed > 0) 
		io_clear_bit(MOTORDIR);
	else if (speed < 0) 
		io_set_bit(MOTORDIR);

	// If to stop (speed == 0)
	else if (last_speed < 0)
		io_clear_bit(MOTORDIR);
	else if (last_speed > 0)
		io_set_bit(MOTORDIR);

	last_speed = speed ;

	// Write new setting to motor.
	io_write_analog(MOTOR, 2048 + 2*abs(speed));

	//printf(__FILE__ ": Speed set to %d\n", speed);
}
示例#2
0
文件: elev.c 项目: torje/heisprosjekt
void elev_set_floor_indicator(int floor) {
    assert(floor >= 0);
    assert(floor < N_FLOORS);

    // Binary encoding. One light must always be on.
    if (floor & 0x02)
        io_set_bit(LIGHT_FLOOR_IND1);
    else
        io_clear_bit(LIGHT_FLOOR_IND1);

    if (floor & 0x01)
        io_set_bit(LIGHT_FLOOR_IND2);
    else
        io_clear_bit(LIGHT_FLOOR_IND2);
}
示例#3
0
文件: elev.c 项目: jhosen/elevator
void elev_set_floor_indicator(int floor)
{
	assert(floor >= 0);
	assert(floor < N_FLOORS);

	if (floor & 0x02)
		io_set_bit(FLOOR_IND1);
	else
		io_clear_bit(FLOOR_IND1);
		
	if (floor & 0x01)
		io_set_bit(FLOOR_IND2);
	else
		io_clear_bit(FLOOR_IND2);
}
示例#4
0
文件: elev.c 项目: mathildh/driver
void elev_set_door_open_lamp(int value) {
    if (value) {
        io_set_bit(LIGHT_DOOR_OPEN);
    } else {
        io_clear_bit(LIGHT_DOOR_OPEN);
    }
}
示例#5
0
文件: elev.c 项目: mathildh/driver
void elev_set_stop_lamp(int value) {
    if (value) {
        io_set_bit(LIGHT_STOP);
    } else {
        io_clear_bit(LIGHT_STOP);
    }
}
示例#6
0
文件: ui.c 项目: sigvartmh/heis3.0
//elev_get_stop_signal=value
void ui_set_stop_lamp(int value)
{
    if (value)
        io_set_bit(LIGHT_STOP);
    else
        io_clear_bit(LIGHT_STOP);
}
示例#7
0
文件: ui.c 项目: sigvartmh/heis3.0
void ui_set_door_open_lamp(int value)
{
    if (value)
        io_set_bit(DOOR_OPEN);
    else
        io_clear_bit(DOOR_OPEN);
}
示例#8
0
文件: ui.c 项目: sigvartmh/heis3.0
void ui_set_floor_indicator(int floor)
{
	// assert crashes the program deliberately if it's condition does not hold,
	// and prints an informative error message. Useful for debugging.
    //assert(floor >= 0);
    //assert(floor < N_FLOORS);

    if (floor & 0x02)
        io_set_bit(FLOOR_IND1);
    else
        io_clear_bit(FLOOR_IND1);
        
    if (floor & 0x01)
        io_set_bit(FLOOR_IND2);
    else
        io_clear_bit(FLOOR_IND2);
}
示例#9
0
文件: elev.c 项目: jhosen/elevator
void elev_set_button_lamp(elev_direction_t lamp, int floor, int value)
{
	assert(floor >= 0);
	assert(floor < N_FLOORS);

	if (value == 1)
		io_set_bit(lamp_channel_matrix[floor][lamp]);
	else
		io_clear_bit(lamp_channel_matrix[floor][lamp]);		
}
示例#10
0
文件: elev.c 项目: torje/heisprosjekt
void elev_set_motor_direction(elev_motor_direction_t dirn) {
    if (dirn == 0){
        io_write_analog(MOTOR, 0);
    } else if (dirn > 0) {
        io_clear_bit(MOTORDIR);
        io_write_analog(MOTOR, 2800);
    } else if (dirn < 0) {
        io_set_bit(MOTORDIR);
        io_write_analog(MOTOR, 2800);
    }
}
示例#11
0
void ElevInterface::set_motor_direction(elev_motor_direction_t dirn) {
    if (dirn == 0) {
        io_write_analog(MOTOR, 0);
    } else if (dirn > 0) {
        io_clear_bit(MOTORDIR);
        io_write_analog(MOTOR, MOTOR_SPEED);
    } else if (dirn < 0) {
        io_set_bit(MOTORDIR);
        io_write_analog(MOTOR, MOTOR_SPEED);
    }
}
示例#12
0
文件: elev.c 项目: torje/heisprosjekt
void elev_set_button_lamp(elev_button_type_t button, int floor, int value) {
    assert(floor >= 0);
    assert(floor < N_FLOORS);
    assert(!(button == BUTTON_CALL_UP && floor == N_FLOORS - 1));
    assert(!(button == BUTTON_CALL_DOWN && floor == 0));
    assert(button == BUTTON_CALL_UP || button == BUTTON_CALL_DOWN || button == BUTTON_COMMAND);

    if (value)
        io_set_bit(lamp_channel_matrix[floor][button]);
    else
        io_clear_bit(lamp_channel_matrix[floor][button]);
}
示例#13
0
文件: elev.c 项目: mathildh/driver
void elev_set_button_lamp(elev_button_type_t button, int floor, int value) {
    assert(floor >= 0);
    assert(floor < N_FLOORS);
    assert(button >= 0);
    assert(button < N_BUTTONS);

    if (value) {
        io_set_bit(lamp_channel_matrix[floor][button]);
    } else {
        io_clear_bit(lamp_channel_matrix[floor][button]);
    }
}
示例#14
0
文件: ui.c 项目: sigvartmh/heis3.0
//maybe let the queue arrays in queues handle button lamps?
//to decrease dependancy
void ui_set_button_lamp(int button, int floor, int value)
{
	// assert crashes the program deliberately if it's condition does not hold,
	// and prints an informative error message. Useful for debugging.
    assert(floor >= 0);
    assert(floor < N_FLOORS);
  //  assert(!(button == BUTTON_CALL_UP && floor == N_FLOORS-1));
  //  assert(!(button == BUTTON_CALL_DOWN && floor == 0));
  //  assert(button == BUTTON_CALL_UP || button == BUTTON_CALL_DOWN || button == BUTTON_COMMAND);

    if (value == 1)
        io_set_bit(lamp_channel_matrix[floor][button]);
    else
        io_clear_bit(lamp_channel_matrix[floor][button]);        
}
示例#15
0
文件: elev.c 项目: jhosen/elevator
void elev_toggle_stop_lamp() {
	if(io_read_bit(LIGHT_STOP))
			io_clear_bit(LIGHT_STOP);
	else
		io_set_bit(LIGHT_STOP);
}