• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ gpio类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中gpio的典型用法代码示例。如果您正苦于以下问题:C++ gpio类的具体用法?C++ gpio怎么用?C++ gpio使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了gpio类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: send_file_to_fpga

static void send_file_to_fpga(std::string &file_name, gpio &error, gpio &done)
{
	std::ifstream bitstream;

	std::cout << "File name - " << file_name.c_str() << std::endl;

	bitstream.open(file_name.c_str(), std::ios::binary);
	if (!bitstream.is_open())
		std::cout << "File " << file_name << " not opened succesfully." << std::endl;

	spidev spi("/dev/spidev1.0");
	char buf[BUF_SIZE];
	char rbuf[BUF_SIZE];

	do {
		bitstream.read(buf, BUF_SIZE);
		spi.send(buf, rbuf, bitstream.gcount());

		if (error.get_value())
			std::cout << "INIT_B went high, error occured." << std::endl;

		if (!done.get_value())
			std::cout << "Configuration complete." << std::endl;

	} while (bitstream.gcount() == BUF_SIZE);
}
开发者ID:vlqk,项目名称:uhd-8bit,代码行数:26,代码来源:fpga-downloader.cpp


示例2: send_file_to_fpga

static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &done)
{
	std::ifstream bitstream;

	bitstream.open(file_name.c_str(), std::ios::binary);
	if (!bitstream.is_open()) throw uhd::os_error(
		"Could not open the file: " + file_name
	);

	spidev spi("/dev/spidev1.0");
	char buf[BUF_SIZE];
	char rbuf[BUF_SIZE];

	do {
		bitstream.read(buf, BUF_SIZE);
		spi.send(buf, rbuf, bitstream.gcount());

		if (error.get_value())
			throw uhd::os_error("INIT_B went high, error occured.");

		if (!done.get_value())
			UHD_MSG(status) << "Configuration complete." << std::endl;

	} while (bitstream.gcount() == BUF_SIZE);
}
开发者ID:Speederc,项目名称:uhd,代码行数:25,代码来源:fpga_downloader.cpp


示例3: button_testing_deinit

/*----------------------------------------------------------------------------*/
void button_testing_deinit(void)
{
	HA_NOTIFY("\n*** Deinitializing hardware ***\n"
	            "All IO pins will be reset to IN_FLOATING\n");
	MB1_up.gpio_shutdown();
	MB1_down.gpio_shutdown();
	MB1_left.gpio_shutdown();
	MB1_right.gpio_shutdown();
	MB1_select.gpio_shutdown();
}
开发者ID:dangnhat,项目名称:HLib,代码行数:11,代码来源:button_testing_cmds.cpp


示例4: led7seg_testing_init

/*----------------------------------------------------------------------------*/
void led7seg_testing_init(void)
{
    HA_NOTIFY("\n*** Initializing hardware for LED7SEG tests ***\n"
            "L1 pin: port: %u (port A = 0,...), pin: %u\n"
            "L2 pin: port: %u (port A = 0,...), pin: %u\n"
            "L3 pin: port: %u (port A = 0,...), pin: %u\n"
            "L4 pin: port: %u (port A = 0,...), pin: %u\n"
            "A pin: port: %u (port A = 0,...), pin: %u\n"
            "B pin: port: %u (port A = 0,...), pin: %u\n"
            "C pin: port: %u (port A = 0,...), pin: %u\n"
            "D pin: port: %u (port A = 0,...), pin: %u\n"
            "h pin: port: %u (port A = 0,...), pin: %u\n",
            l1_params.port, l1_params.pin,
            l2_params.port, l2_params.pin,
            l3_params.port, l3_params.pin,
            l4_params.port, l4_params.pin,
            a_params.port, a_params.pin,
            b_params.port, b_params.pin,
            c_params.port, c_params.pin,
            d_params.port, d_params.pin,
            h_params.port, h_params.pin);

    MB1_L1.gpio_init(&l1_params);
    MB1_L2.gpio_init(&l2_params);
    MB1_L3.gpio_init(&l3_params);
    MB1_L4.gpio_init(&l4_params);

    MB1_A.gpio_init(&a_params);
    MB1_B.gpio_init(&b_params);
    MB1_C.gpio_init(&c_params);
    MB1_D.gpio_init(&d_params);
    MB1_h.gpio_init(&h_params);

}
开发者ID:dangnhat,项目名称:HLib,代码行数:35,代码来源:led7seg_testing_cmds.cpp


示例5: button_testing

/*----------------------------------------------------------------------------*/
void button_testing(void)
{
	start_waiting_esc_character();

	HA_NOTIFY("\n*** BUTTON & MBOARD TEST ***\n"
	                "(press ESC to quit).\n");

	while(1)
	{
		if(is_press_button(MB1_up.gpio_read()))
		{
			testing_delay_us(10000);
			while(is_press_button(MB1_up.gpio_read()));
			HA_NOTIFY("Press button UP.\n");
		}
		if(is_press_button(MB1_down.gpio_read()))
		{
			testing_delay_us(10000);
			while(is_press_button(MB1_down.gpio_read()));
			HA_NOTIFY("Press button DOWN.\n");
		}
		if(is_press_button(MB1_left.gpio_read()))
		{
			testing_delay_us(10000);
			while(is_press_button(MB1_left.gpio_read()));
			HA_NOTIFY("Press button LEFT.\n");
		}
		if(is_press_button(MB1_right.gpio_read()))
		{
			testing_delay_us(10000);
			while(is_press_button(MB1_right.gpio_read()));
			HA_NOTIFY("Press button RIGHT.\n");
		}
		if(is_press_button(MB1_select.gpio_read()))
		{
			testing_delay_us(10000);
			while(is_press_button(MB1_select.gpio_read()));
			HA_NOTIFY("Press button SELECT.\n");
		}

		/* poll the esc_pressed */
		if (esc_pressed == true) {
		    break;
		}
	}//End while().

    stop_waiting_esc_character();
    HA_NOTIFY("Test stopped.\n");
}
开发者ID:dangnhat,项目名称:HLib,代码行数:50,代码来源:button_testing_cmds.cpp


示例6: led7seg_testing_deinit

/*----------------------------------------------------------------------------*/
void led7seg_testing_deinit(void)
{
    HA_NOTIFY("\n*** Deinitializing hardware ***\n"
            "All IO pins will be reset to IN_FLOATING\n");

    /* Shutdown GPIOs */
    MB1_L1.gpio_shutdown();
    MB1_L2.gpio_shutdown();
    MB1_L3.gpio_shutdown();
    MB1_L4.gpio_shutdown();
    MB1_A.gpio_shutdown();
    MB1_B.gpio_shutdown();
    MB1_C.gpio_shutdown();
    MB1_D.gpio_shutdown();
    MB1_h.gpio_shutdown();
}
开发者ID:dangnhat,项目名称:HLib,代码行数:17,代码来源:led7seg_testing_cmds.cpp


示例7: button_testing_init

/*----------------------------------------------------------------------------*/
void button_testing_init(void)
{
    HA_NOTIFY("up pin: port: %u (port A = 0,...), pin: %u.\n"
    		"down pin: port: %u (port A = 0,...), pin: %u.\n"
    		"left pin: port: %u (port A = 0,...), pin: %u.\n"
    		"right pin: port: %u (port A = 0,...), pin: %u.\n"
    		"select pin: port: %u (port A = 0,...), pin: %u.\n",
            up_params.port, up_params.pin,
			down_params.port, down_params.pin,
			left_params.port, left_params.pin,
			right_params.port, right_params.pin,
			select_params.port, select_params.pin);

    MB1_up.gpio_init(&up_params);
    MB1_down.gpio_init(&down_params);
    MB1_left.gpio_init(&left_params);
    MB1_right.gpio_init(&right_params);
    MB1_select.gpio_init(&select_params);
    testing_delay_us(100000);
}
开发者ID:dangnhat,项目名称:HLib,代码行数:21,代码来源:button_testing_cmds.cpp


示例8: sim900_testing_init

/*----------------------------------------------------------------------------*/
static void sim900_testing_init(void)
{
    HA_NOTIFY("\nInitializing hardware for sim900 tests\n"
            "USART: %u, Baudrate: %lu\n"
            "RI pin: port: %u (port A = 0,...), pin: %u\n",
            uart_num, baudrate,
            RI_params.port, RI_params.pin);

    /* Initialize UART */
    MB1_usart.Restart(baudrate);
    MB1_usart.it_enable(0,1);
    MB1_usart.it_config(USART_IT_RXNE, ENABLE);
    MB1_int.subISR_assign(MB1_int_type, usart3_irq);

    /* Init RI pin */
    RI_pin.gpio_init(&RI_params);

    HA_NOTIFY("\nRI: %d (should be 1)\n", RI_pin.gpio_read());

    /* Create ring buffer */
    rb_init(&rx_buffer, 128);
}
开发者ID:dangnhat,项目名称:HLib,代码行数:23,代码来源:sim900_testing_cmds.cpp


示例9: prepare_fpga_for_configuration

static void prepare_fpga_for_configuration(gpio &prog, gpio &)//init)
{

	prog.set_value(true);
	prog.set_value(false);
	prog.set_value(true);

#if 0
	bool ready_to_program(false);
	unsigned int count(0);
	do {
		ready_to_program = init.get_value();
		count++;

		sleep(1);
	} while (count < 10 && !ready_to_program);

	if (count == 10) {
		throw uhd::os_error("FPGA not ready for programming.");
	}
#endif
}
开发者ID:Speederc,项目名称:uhd,代码行数:22,代码来源:fpga_downloader.cpp


示例10: prepare_fpga_for_configuration

static void prepare_fpga_for_configuration(gpio &prog, gpio &init)
{

	prog.set_value(true);
	prog.set_value(false);
	prog.set_value(true);

#if 0
	bool ready_to_program(false);
	unsigned int count(0);
	do {
		ready_to_program = init.get_value();
		count++;

		sleep(1);
	} while (count < 10 && !ready_to_program);

	if (count == 10) {
		std::cout << "FPGA not ready for programming." << std::endl;
		exit(-1);
	}
#endif
}
开发者ID:vlqk,项目名称:uhd-8bit,代码行数:23,代码来源:fpga-downloader.cpp


示例11: sim900_testing_deinit

/*----------------------------------------------------------------------------*/
static void sim900_testing_deinit(void)
{
    HA_NOTIFY("\n*** Deinitializing hardware ***\n"
            "USART: %u, will be shut down\n"
            "All IO pins will be reset to IN_FLOATING\n",
            uart_num);

    /*Deinit USART and INT*/
    MB1_int.subISR_remove(ISRMgr_ns::ISRMgr_USART3, usart3_irq);
    MB1_usart.it_disable();
    MB1_usart.Shutdown();

    /* Deinit RI pin */
    RI_pin.gpio_shutdown();

    rb_clear(&rx_buffer);
}
开发者ID:dangnhat,项目名称:HLib,代码行数:18,代码来源:sim900_testing_cmds.cpp


示例12: led_data

/* LED7SEG function */
void led_data(uint8_t number, bool h)
{
    switch (number){
    /* Number 0 */
    case 0:
        MB1_A.gpio_assign_value(!data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 1 */
    case 1:
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 2 */
    case 2:
        MB1_A.gpio_assign_value(!data_set_value);
        MB1_B.gpio_assign_value(data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 3 */
    case 3:
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 4 */
    case 4:
        MB1_A.gpio_assign_value(!data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 5 */
    case 5:
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 6 */
    case 6:
        MB1_A.gpio_assign_value(!data_set_value);
        MB1_B.gpio_assign_value(data_set_value);
        MB1_C.gpio_assign_value(data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 7 */
    case 7:
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(data_set_value);
        MB1_C.gpio_assign_value(data_set_value);
        MB1_D.gpio_assign_value(!data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 8 */
    case 8:
        MB1_A.gpio_assign_value(!data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    /* Number 9 */
    case 9:
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(!data_set_value);
        MB1_C.gpio_assign_value(!data_set_value);
        MB1_D.gpio_assign_value(data_set_value);
        MB1_h.gpio_assign_value(h);
        break;

    default:
        HA_NOTIFY("Data must be 0 ~ 9.\n");
        MB1_A.gpio_assign_value(data_set_value);
        MB1_B.gpio_assign_value(data_set_value);
        MB1_C.gpio_assign_value(data_set_value);
        MB1_D.gpio_assign_value(data_set_value);
//.........这里部分代码省略.........
开发者ID:dangnhat,项目名称:HLib,代码行数:101,代码来源:led7seg_testing_cmds.cpp


示例13: sim900_gsm_test

static void sim900_gsm_test(void)
{
    uint8_t state = 0, data, ri = 0;

    start_waiting_esc_character();

    HA_NOTIFY("\nTEST #2: GSM TEST\n"
            "This test calls *101# to check money account\n"
            "(Press ESC to continue)\n");

    while (esc_pressed == false);
    stop_waiting_esc_character();

    /* Clear buffer brfore testing */
    rb_clear(&rx_buffer);

    HA_NOTIFY("\nCalling *101# ... \n");

    /* Call *101# */
    MB1_usart.Print("ATD*101#;\r");

    start_waiting_esc_character();

    while(1)
    {
        /* Receiving message */
        if (rb_get_data(&rx_buffer,&data,1) > 0)
        {
            switch (state)
            {
            /* Print content between two " " */
            case 0:
                if (data == '"')
                {
                    state = 1;
                    HA_NOTIFY("\nReceived Message: \n");

                    /*check RI pin*/
                    if (RI_pin.gpio_read() == 0) ri = 1;
                }
                break;

            case 1:
                if (data == '"')
                {
                    state = 2;
                    HA_NOTIFY("\n");
                }
                else
                {
                    HA_NOTIFY("%c", (char)data);
                }
                break;

            /* End of message */
            case 2:
                if (data == '\r')
                {
                    state = 3;
                    HA_NOTIFY("\nSuccessful !\n");
                }
                break;
            }

        }

        if (esc_pressed == true)
        {
            break;
        }
    }

    stop_waiting_esc_character();

    /* Fail to receive message */
    if (state != 3)
    {
        HA_NOTIFY("\nFail\n");
    }
    else
    {
        if (ri == 1)
        {
            HA_NOTIFY("\nRI pin works\n");
        }
        else
        {
            HA_NOTIFY("\nRI pin does not work\n");
        }
    }
}
开发者ID:dangnhat,项目名称:HLib,代码行数:91,代码来源:sim900_testing_cmds.cpp


示例14: led_number

void led_number(uint8_t lednumber)
{
    switch (lednumber){
    case all:
        MB1_L1.gpio_assign_value(l_enable_value);
        MB1_L2.gpio_assign_value(l_enable_value);
        MB1_L3.gpio_assign_value(l_enable_value);
        MB1_L4.gpio_assign_value(l_enable_value);
        break;
    case 1:
        MB1_L1.gpio_assign_value(l_enable_value);
        MB1_L2.gpio_assign_value(!l_enable_value);
        MB1_L3.gpio_assign_value(!l_enable_value);
        MB1_L4.gpio_assign_value(!l_enable_value);
        break;
    case 2:
        MB1_L1.gpio_assign_value(!l_enable_value);
        MB1_L2.gpio_assign_value(l_enable_value);
        MB1_L3.gpio_assign_value(!l_enable_value);
        MB1_L4.gpio_assign_value(!l_enable_value);
        break;
    case 3:
        MB1_L1.gpio_assign_value(!l_enable_value);
        MB1_L2.gpio_assign_value(!l_enable_value);
        MB1_L3.gpio_assign_value(l_enable_value);
        MB1_L4.gpio_assign_value(!l_enable_value);
        break;
    case 4:
        MB1_L1.gpio_assign_value(!l_enable_value);
        MB1_L2.gpio_assign_value(!l_enable_value);
        MB1_L3.gpio_assign_value(!l_enable_value);
        MB1_L4.gpio_assign_value(l_enable_value);
        break;
    default:
        HA_NOTIFY("You can choose led_number 1 ~ 4.\n");
        MB1_L1.gpio_assign_value(!l_enable_value);
        MB1_L2.gpio_assign_value(!l_enable_value);
        MB1_L3.gpio_assign_value(!l_enable_value);
        MB1_L4.gpio_assign_value(!l_enable_value);
        break;
    }//End switch case
}
开发者ID:dangnhat,项目名称:HLib,代码行数:42,代码来源:led7seg_testing_cmds.cpp


示例15: CallDisplayOkMessage

void PinTinDisplay::CallDisplayOkMessage(char* title)
{
	bool isConfirmed = false;
	bool buttonHasBeenReleased = false;
	int currentRow = 0;
	
	this->oled.setCursor(0, 0);
	this->oled.clear(PAGE);
	oled.print(title);
	this->oled.setCursor(48, 40);
	this->oled.print("OK");
	this->oled.setDrawMode(XOR);
	this->oled.rectFill(46, 38, 14, 12);
	this->oled.setDrawMode(NORM);
	this->oled.display();
					
	while(!isConfirmed)
	{
		usleep(2000);
		
		if (BUTTON_UP.pinRead() == HIGH &&
		BUTTON_DOWN.pinRead() == HIGH &&
		BUTTON_SELECT.pinRead() == HIGH)
			buttonHasBeenReleased = true;

		if (BUTTON_SELECT.pinRead() == LOW && buttonHasBeenReleased){
			buttonHasBeenReleased = false;
			isConfirmed = true;
		}
	}
}
开发者ID:DanielGilbert,项目名称:PinTinNano,代码行数:31,代码来源:pintin_display.cpp


示例16: begin

/** \brief Initialization of edOLED Library.

    Setup IO pins for SPI port then send initialization commands to the
    SSD1306 controller inside the OLED.
*/
void edOLED::begin()
{
	// default 5x7 font
	setFontType(0);
	setColor(WHITE);
	setDrawMode(NORM);
	setCursor(0,0);
	
	spiSetup();
	
	RST_PIN.pinWrite(HIGH); //(digitalWrite(rstPin, HIGH);
	usleep(5000); // VDD (3.3V) goes high at start, lets just chill for 5 ms
	RST_PIN.pinWrite(LOW); // bring reset low
	usleep(10000); // wait 10ms
	RST_PIN.pinWrite(HIGH);	//digitalWrite(rstPin, HIGH);

	// Init sequence for 64x48 OLED module
	command(DISPLAYOFF);			// 0xAE

	command(SETDISPLAYCLOCKDIV);	// 0xD5
	command(0x80);					// the suggested ratio 0x80

	command(SETMULTIPLEX);			// 0xA8
	command(0x2F);

	command(SETDISPLAYOFFSET);		// 0xD3
	command(0x0);					// no offset

	command(SETSTARTLINE | 0x0);	// line #0

	command(CHARGEPUMP);			// enable charge pump
	command(0x14);

	command(NORMALDISPLAY);			// 0xA6
	command(DISPLAYALLONRESUME);	// 0xA4

	command(SEGREMAP | 0x1);
	command(COMSCANDEC);

	command(SETCOMPINS);			// 0xDA
	command(0x12);

	command(SETCONTRAST);			// 0x81
	command(0x8F);

	command(SETPRECHARGE);			// 0xd9
	command(0xF1);
	
	command(SETVCOMDESELECT);			// 0xDB
	command(0x40);

	command(DISPLAYON);				//--turn on oled panel
	clear(ALL);						// Erase hardware memory inside the OLED
}
开发者ID:MusicalCreeper01,项目名称:9DOF_OLED_Readout,代码行数:59,代码来源:Edison_OLED.cpp


示例17: data

/** \brief SPI data.

    Setup DC and SS pins, then send data via SPI to SSD1306 controller.
*/
void edOLED::data(unsigned char c)
{
	DC_PIN.pinWrite(HIGH);	// DC HIGH
	spiTransfer(c);
}
开发者ID:MusicalCreeper01,项目名称:9DOF_OLED_Readout,代码行数:9,代码来源:Edison_OLED.cpp


示例18: command

/** \brief SPI command.

    Setup DC and SS pins, then send command via SPI to SSD1306 controller.
*/
void edOLED::command(unsigned char c)
{
	DC_PIN.pinWrite(LOW); // DC pin LOW
	spiTransfer(c);
}
开发者ID:MusicalCreeper01,项目名称:9DOF_OLED_Readout,代码行数:9,代码来源:Edison_OLED.cpp


示例19: menu

int PinTinDisplay::menu(void)
{
	bool isConfirmed = false;
	bool buttonHasBeenReleased = false;
	int currentRow = 0;
	
	while(!isConfirmed)
	{
		usleep(2000);
		
		if (BUTTON_UP.pinRead() == HIGH &&
		BUTTON_DOWN.pinRead() == HIGH &&
		BUTTON_SELECT.pinRead() == HIGH)
			buttonHasBeenReleased = true;
		
		oled.setCursor(0, 0);
		oled.clear(PAGE);
		if (currentRow == 0)
			oled.print(">     LIST");
		else
			oled.print("      List");
		if (currentRow == 1)
			oled.print(">     FIND");
		else
			oled.print("      Find");
		oled.print("----------");
		if (currentRow == 2)
			oled.print(">      NEW");
		else
			oled.print("       New");
		if (currentRow == 3)
			oled.print(">     EDIT");
		else
			oled.print("      Edit");
		if (currentRow == 4)
			oled.print(">   DELETE");
		else
			oled.print("    Delete");
		
		oled.display();
		
		if (BUTTON_UP.pinRead() == LOW && buttonHasBeenReleased){
			currentRow--;
			if (currentRow < 0){
				currentRow = 4;
			}
			buttonHasBeenReleased = false;
		}
		
		if (BUTTON_DOWN.pinRead() == LOW && buttonHasBeenReleased){
			currentRow++;
			if (currentRow > 4){
				currentRow = 0;
			}
			buttonHasBeenReleased = false;
		}
		
		if (BUTTON_SELECT.pinRead() == LOW && buttonHasBeenReleased){
			buttonHasBeenReleased = false;
			oled.clear(PAGE);
			oled.display();
			return currentRow;
		}
	}
}
开发者ID:DanielGilbert,项目名称:PinTinNano,代码行数:65,代码来源:pintin_display.cpp


示例20: DisplayEntry

int PinTinDisplay::DisplayEntry(char* uri, char* username, char* password, char* note)
{
	int currentPage = 1;
	int totalPages = 4;
	bool isReturning = false;
	bool buttonHasBeenReleased = false;
	
	do{
		usleep(2000);
		
		this->oled.setCursor(0, 0);
		this->oled.clear(PAGE);
		
		switch(currentPage){
			case 1:
				this->oled.print("Uri:");
				this->oled.setCursor(0, 8);
				this->oled.print(uri);
			break;
			
			case 2:
				this->oled.print("Username:");
				this->oled.setCursor(0, 8);
				this->oled.print(username);
			break;
			
			case 3:
				this->oled.print("Password");
				this->oled.setCursor(0, 8);
				this->oled.print(password);
			break;
			
			case 4:
				this->oled.print("Note:");
				this->oled.setCursor(0, 8);
				this->oled.print(note);
			break;
		}

		this->oled.display();
		//Draw the selection
	
		if (BUTTON_LEFT.pinRead() == LOW && buttonHasBeenReleased){
			isReturning = true;
			buttonHasBeenReleased = false;
		}

		if (BUTTON_A.pinRead() == LOW && buttonHasBeenReleased){
			currentPage--;
			if (currentPage < 1)
				currentPage = totalPages;
			buttonHasBeenReleased = false;
		}
		
		if (BUTTON_B.pinRead() == LOW && buttonHasBeenReleased){
			currentPage++;
			
			if (currentPage > totalPages)
			{
				currentPage = 1;
			}
			
			buttonHasBeenReleased = false;
		}

		if (BUTTON_UP.pinRead() == HIGH &&
			BUTTON_DOWN.pinRead() == HIGH &&
			BUTTON_RIGHT.pinRead() == HIGH &&
			BUTTON_LEFT.pinRead() == HIGH &&
			BUTTON_SELECT.pinRead() == HIGH &&
			BUTTON_A.pinRead() == HIGH &&
			BUTTON_B.pinRead() == HIGH)
			buttonHasBeenReleased = true;
		
	} while (!isReturning);
	
	
	return -1;
}
开发者ID:DanielGilbert,项目名称:PinTinNano,代码行数:79,代码来源:pintin_display.cpp



注:本文中的gpio类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ graph类代码示例发布时间:2022-05-31
下一篇:
C++ gp_Pnt类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap