- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些驱动程序代码,正在测试它们是否与 SSD1306 驱动的 OLED 屏幕(128x32)(与 OLED adafruit 型号相同)一起使用。我需要它在 debian 中运行(我正在使用 Linario-4.4.9
)
我已按照 Debian 指南了解如何开始为设备创建文件处理程序,如下所示。 oled.h
中唯一的内容是设备地址 (0x3C
) 和原型(prototype)类型。我遵循了 adafruit github 上采取的初始化方法(因为我首先在 Ardunio 上尝试了他们的代码,以确保屏幕确实工作)。我相信我可能做错了什么,但我不完全确定我做错了什么。我还在下面列出了我的初始化过程。
#include <errno.h>
#include <stdint.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <linux/i2c-dev.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "oled.h"
int oled;
int lcd_driver_init(void)
{
///< Begin the init proc.
int dloc = open("/dev/i2c-1", O_RDWR);
if (dloc < 0 )
{
fprintf(stderr, "Error opening i2c device\n");
return -1;
}
if(ioctl(dloc, I2C_SLAVE, SCR_ADDR) < 0)
{
fprintf(stderr, "Error in ioctl. Errno :%i\n",errno);
return -2;
}
oled = dloc;
fprintf(stderr, "init success, device open and local\n");
return EXIT_SUCCESS;
}
int oled_command( uint8_t cmd)
{
char command[2]= {0};
command[1] = cmd;
int check = (write(oled, command, 2));
return check;
}
void oled_cmd_start()
{
int check = (write(oled, 0x00, sizeof(uint8_t)));
if(check<0)
fprintf(stderr, "Errno set:: %i\n", errno);
return;
}
void oled_data_start()
{
uint8_t _data_start_[1] ={ 0x40 };
int check = (write(oled, _data_start_, sizeof(uint8_t)));
if(check<0)
fprintf(stderr, "Errno set oled_data_start:: %i\n", errno);
return;
}
int oled_data (uint8_t xmit)
{
int check = (write(oled, &xmit, (sizeof(uint8_t))));
if(check<0)
fprintf(stderr, "Errno set oled_data:: %i\n", errno);
return check;
}
void sendcommand(unsigned char payload)
{
oled_data(0x00); //Control Byte - Command
oled_data(payload); //payload
}
void lcd_init(void)
{
sendcommand(0xAE);//--Set Display off
sendcommand(0x00);//--set low column address
sendcommand(0x10);//--set high column address
sendcommand(0x81);//--set contrast control register
sendcommand(0x7f);
sendcommand(0xa1);//--set segment re-map 95 to 0
sendcommand(0xA6);//--set normal display
sendcommand(0xa8);//--set multiplex ratio(1 to 16)
sendcommand(0x1f);//--duty 1/32
sendcommand(0xd3);//--set display offset
sendcommand(0x00);//--not offset
sendcommand(0xd5);//--set display clock divide ratio/oscillator frequency
sendcommand(0xf0);//--set divide ratio
sendcommand(0xd9);//--set pre-charge period
sendcommand(0x22);
sendcommand(0xda);//--set com pins hardware configuration
sendcommand(0x02);//disable left/right remap and set for sequential
sendcommand(0xdb);//--set vcomh
sendcommand(0x49);//--0.83*vref
sendcommand(0x8d);//--set DC-DC enable
sendcommand(0x14);//
sendcommand(0xAF);//--turn on oled panel
sendcommand(0xA4);//--Entire Display ON
}
接下来,我发送交替的 0xFF
来尝试在屏幕上制作条纹。唯一显示的是随机像素。没有连贯性。
我已连接逻辑分析仪来嗅探 I2C 线路,当我连接 LA 时,I2C 线路似乎不再起作用,并且 ERRNO
返回 IO 故障 (#5)。然而,打开设备来获取文件指针似乎从来没有出现过问题。
有时我确实会收到 ERRNO
作为超时,但我读到这只是使用协议(protocol)的 I2C 设备的问题,因为 write
期望比 I2C 更快的响应给。
我还使用 -std=c99 -O0
进行编译,以确保所有内联函数都存在,并确保循环变量可用。
如果有人能指出我正确的方向或指出我的方法中的一些缺陷,我将不胜感激。谢谢。
我检查了设备树并且 i2c 设备已正确启用。然而,i2c_freq
速度似乎均未启用。这是否会导致超时和垃圾数据传输?
最佳答案
I have connected a logic analyzer to sniff the I2C lines, and it appears that when I have the LA connected, the I2C lines no longer function and ERRNO returns an IO fault (#5).
逻辑分析仪只是一种测量设备。它将捕获的数据转换为时序图,解码您设置的协议(protocol)。因此,它不会对任何 I2C 读写错误负责(直到您的接地和硬件连接正确)。
对于超时问题,您可以尝试降低i2c时钟频率
或ioctl I2C_TIMEOUT
。
关于c - 用于 OLED 屏幕的 Debian I2C 驱动程序不起作用。 [SSD1306],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43333649/
在Debian的最新稳定版本中似乎没有/etc/rc.local Debian Stretch 。它在哪里? /etc/rc.local已过时吗? 最佳答案 rc.local已弃用。 看来您仍然可以拥
尝试从未签名的存储库将 Debian 软件包安装到 Debian 9: # apt-get --allow-unauthenticated update Get:1 http://files.free
我尝试打开 5431 端口,这样输入: sudo iptables -A INPUT -p tcp --dport 5431 --jump ACCEPT iptables-save 当我在链 ipta
我正在尝试为我的应用程序构建一个预编译的 debian 包。我的包中存在一些二进制文件(编译模块)。现在,我收到有关将二进制文件添加到 debian/source/include-binaries 的
Debian 站点很棒 http://www.debian.org/distrib/packages ,我知道搜索工具,但我真的想要一个完整的包/文件/架构目录,采用某种可使用的格式 - xml、js
Debian 如何管理软件包名称的冲突?例如,当不同的存储库中有许多同名的包时。 最佳答案 当有很多同名的包时,APT 怎么知道它们是不同的呢? 不能。所以它会安装版本号最高的版本。 关于debian
我正在构建一个 Debian 软件包,它通过将许多其他紧密相关的软件包声明为依赖项来收集它们。我希望这些依赖项与包的版本完全相同。 Debian 构建系统中有没有办法避免在控制文件中硬编码(除了自己预
我有一个持续集成服务器构建一些软件,这些软件依赖于比 debian squeeze 中提供的 apt 包更新的 libqt4-dev 版本。该版本在 debian wheezy 中可用。我如何告诉 a
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我在 debian 上安装了一个带有 xfce4 的新系统。我的问题是如何让 xfce 在启动时运行?现在我只能用 exec ck-launch-session startxfce4 运行它。 谢谢
我听说我可以使用 apt-get install libc6 来完成此操作,但我需要向/etc/apt/sources.list 添加一些内容才能接收最新的 glibc 版本。 我应该做什么? 最佳答
嗨,我正在尝试在运行 rasbian wheezy 的树莓派上安装 geos,以便我可以在我的 python 脚本中包含 shapely 模块。我尝试使用: git clone git://git.d
您好,我正在尝试在运行 rasbian wheezy 的树莓派上安装 geos,这样我就可以在我的 python 脚本中包含 shapely 模块。我尝试使用:git clone git://git.
我正在尝试在 Debian 8.5.0 上安装 GitLab。我关注installation guide但最后一步失败了,我在文档中找不到任何信息。 gitlab-ctl 重新配置完成 Running
我已经安装了 jetty 9,但我无法将它作为服务启动/停止。 从命令行运行有效。 root@backend:/opt/jetty# service jetty start Job for jetty
我正在寻找一种快速方法来验证 debian/control我的项目文件在将它们发送到构建服务器之前在语法上是有效的。 (即等效于 apache2ctl configtest 但对于 debian 控制
[相关部分] 我的 bitbucket-pipeline 看起来像这样: - step: image: python:3.5.1 name: upload to s3
当我下载一些包源时,(例如foo-[ver].orig.tar.gz、foo-[ver].dsc),我在使用dpkg-source -x foo-[ver].dsc时经常遇到依赖问题。和 dpkg-b
我有一台旧的专用服务器,想将其升级到最新的操作系统版本。 我正在寻找从 升级的最佳方式Debian 6 Squeeze => Debian 8.6 杰西 . 最佳答案 首先,请记住,从一个 Debia
我正在尝试使用 Cpack 构建一个正确命名的 Debian 包。我的 CMakeLists.txt 中有以下内容: set(CPACK_PACKAGE_NAME "something") set(C
我是一名优秀的程序员,十分优秀!