小编Mar*_*ven的帖子

将uint_8更改为x乘以二进制1 MSB

我正在为我的学校项目编写一个Max72xx库,我找到了一种使用数据表附带的寄存器设置列的方法.现在,我也找到了一种设定高度的方法.所以我创建了一个带有两个参数的函数:row基本上将x轴发送到芯片,以及设置y轴的高度.

我在这段代码中所做的基本上如下:

  • 用户将x轴设置在1到8之间(参数const uint8_t& row)
  • 用户将y轴设置在1到8之间(参数uint8_t height)

我想实现以下目标:

  • 如果height设置为3:应创建以下位模式:1110 000.或者,如果用户使用8,我希望创建该功能1111 1111.或者如果用户将5设置为y轴,我希望fucntin创建一个位模式1111 1000,等等.

我提供的代码如下(这段代码在函数setColumn中):

if (height >= 1 && height <= 8) { // if the height is between the matrix range
    uint8_t pattern = 0x00; // create a pattern to send to the chip
    uint8_t counter = 0; // counter for counting the zeros to shift left later on

    for (uint8_t i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c++ hardware

3
推荐指数
1
解决办法
66
查看次数

标签 统计

c++ ×1

hardware ×1