苏金卡 2022-11-21 13:26 采纳率: 0%
浏览 5

如何在u8g2中设置菜单引脚?

遇到的问题

我移植u8g2到stm32上,但是发现无法控制菜单,如何在u8g2中的gpio_and_delay中设置菜单引脚?下载是我的gpio_and_delay函数:

代码
uint8_t u8x8_stm32_gpio_and_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{
  switch(msg)
  {
    case U8X8_MSG_GPIO_AND_DELAY_INIT:    // called once during init phase of u8g2/u8x8
      break;                            // can be used to setup pins
    case U8X8_MSG_DELAY_NANO:            // delay arg_int * 1 nano second
      break;    
    case U8X8_MSG_DELAY_100NANO:        // delay arg_int * 100 nano seconds
            __NOP();
      break;
    case U8X8_MSG_DELAY_10MICRO:        // delay arg_int * 10 micro seconds
            for (uint16_t n = 0; n < 320; n++)
            {
                __NOP();
            }
      break;
    case U8X8_MSG_DELAY_MILLI:            // delay arg_int * 1 milli second
            HAL_Delay(arg_int);
      break;
    case U8X8_MSG_DELAY_I2C:                // arg_int is the I2C speed in 100KHz, e.g. 4 = 400 KHz
      break;                            // arg_int=1: delay by 5us, arg_int = 4: delay by 1.25us
    case U8X8_MSG_GPIO_D0:                // D0 or SPI clock pin: Output level in arg_int
    //case U8X8_MSG_GPIO_SPI_CLOCK:
      break;
    case U8X8_MSG_GPIO_D1:                // D1 or SPI data pin: Output level in arg_int
    //case U8X8_MSG_GPIO_SPI_DATA:
      break;
    case U8X8_MSG_GPIO_D2:                // D2 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_D3:                // D3 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_D4:                // D4 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_D5:                // D5 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_D6:                // D6 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_D7:                // D7 pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_E:                // E/WR pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_CS:                // CS (chip select) pin: Output level in arg_int
            //if (arg_int) HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
            //else HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
        
            if (arg_int) HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
            else HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
      break;
    case U8X8_MSG_GPIO_DC:                // DC (data/cmd, A0, register select) pin: Output level in arg_int
            if (arg_int) HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_SET);
            else HAL_GPIO_WritePin(DC_GPIO_Port, DC_Pin, GPIO_PIN_RESET);
      break;
    case U8X8_MSG_GPIO_RESET:            // Reset pin: Output level in arg_int
            if (arg_int) HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_SET);
            else HAL_GPIO_WritePin(RST_GPIO_Port, RST_Pin, GPIO_PIN_RESET);
      break;
    case U8X8_MSG_GPIO_CS1:                // CS1 (chip select) pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_CS2:                // CS2 (chip select) pin: Output level in arg_int
      break;
    case U8X8_MSG_GPIO_I2C_CLOCK:        // arg_int=0: Output low at I2C clock pin
      break;                            // arg_int=1: Input dir with pullup high for I2C clock pin
    case U8X8_MSG_GPIO_I2C_DATA:            // arg_int=0: Output low at I2C data pin
      break;                            // arg_int=1: Input dir with pullup high for I2C data pin
    case U8X8_MSG_GPIO_MENU_SELECT:
      u8x8_SetGPIOResult(u8x8, /* get menu select pin state */ 0);
      break;
    case U8X8_MSG_GPIO_MENU_NEXT:
      u8x8_SetGPIOResult(u8x8, /* get menu next pin state */ 0);
      break;
    case U8X8_MSG_GPIO_MENU_PREV:
      u8x8_SetGPIOResult(u8x8, /* get menu prev pin state */ 0);
      break;
    case U8X8_MSG_GPIO_MENU_HOME:
      u8x8_SetGPIOResult(u8x8, /* get menu home pin state */ 0);
      break;
    default:
      u8x8_SetGPIOResult(u8x8, 1);            // default return value
      break;
  }
  return 1;
}


  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 创建了问题 11月21日

      悬赏问题

      • ¥20 如何从 .html url 启动/激活 .py 文件(sql debug)
      • ¥15 c#调用soap出错,soapui中可以
      • ¥100 CBIS-DDSM kaggle 资料处理
      • ¥30 python 在 excel 用 OpenPyXL 怎么实现以下代码
      • ¥15 pywinauto 无法捕获到元素
      • ¥15 ARfoundation (可能由于没打开摄像头的)黑屏问题
      • ¥15 C++类模板继承模板本身,有偿
      • ¥15 pycharm打包项目包含mp3文件,运行exe程序后mp3文件没有执行。
      • ¥15 Quantlib求discount factors
      • ¥15 JS宏提取满足比率的字符区段