最终实现:利用python和web.py写一个页面,从而达到,在手机端页面上点击按钮可以控制投影仪的操作。

前提:树莓派已经可以控制投影仪,在之前的文章中写过。

(25条消息) 树莓派驱动DLPDLCR230NPEVM+framebuffer显示图片_L_Y000的博客-CSDN博客

手机端界面如下。如图,点击“开始”按键,即可打开投影仪投射树莓派桌面。

网页端利用python的web.py搭建。

总体文件夹如下图。

其中api文件夹、i2c、linuxi2c是投影仪调用的文件。

static文件夹如下。

app.py

import web
import programurls = ('/start', 'start'
)
app = web.application(urls, globals())class start:def GET(self):return program.something()if __name__ == "__main__":app.run()

program.py(将之前的init_parallel_mode.py改写进来就好),即program.py的功能就是按键按下所需要实现的功能。

import struct
import timefrom enum import Enumimport sys, os.path
python_dir = (os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
sys.path.append(python_dir)
from api.dlpc343x_xpr4 import *
from api.dlpc343x_xpr4_evm import *
from linuxi2c import *
import i2cclass Set(Enum):Disabled = 0Enabled = 1def something():'''Initializes the Raspberry Pi's GPIO lines to communicate with the DLPDLCR230NPEVM,and configures the DLPDLCR230NPEVM to project RGB666 parallel video input received from the Raspberry Pi.It is recommended to execute this script upon booting the Raspberry Pi.'''gpio_init_enable = True          # Set to FALSE to disable default initialization of Raspberry Pi GPIO pinouts. TRUE by default.i2c_time_delay_enable = False    # Set to FALSE to prevent I2C commands from waiting. May lead to I2C bus hangups with some commands if FALSE.i2c_time_delay = 0.8             # Lowering this value will speed up I2C commands. Too small delay may lead to I2C bus hangups with some commands.protocoldata = ProtocolData()def WriteCommand(writebytes, protocoldata):'''Issues a command over the software I2C bus to the DLPDLCR230NP EVM.Set to write to Bus 7 by defaultSome commands, such as Source Select (splash mode) may perform asynchronous access to the EVM's onboard flash memory.If such commands are used, it is recommended to provide appropriate command delay to prevent I2C bus hangups.'''# print ("Write Command writebytes ", [hex(x) for x in writebytes])if(i2c_time_delay_enable): time.sleep(i2c_time_delay)i2c.write(writebytes)       returndef ReadCommand(readbytecount, writebytes, protocoldata):'''Issues a read command over the software I2C bus to the DLPDLCR230NP EVM.Set to read from Bus 7 by defaultSome commands, such as Source Select (splash mode) may perform asynchronous access to the EVM's onboard flash memory.If such commands are used, it is recommended to provide appropriate command delay to prevent I2C bus hangups.'''# print ("Read Command writebytes ", [hex(x) for x in writebytes])if(i2c_time_delay_enable): time.sleep(i2c_time_delay)i2c.write(writebytes) readbytes = i2c.read(readbytecount)return readbytes# ##### ##### Initialization for I2C ##### ###### register the Read/Write Command in the Python libraryDLPC343X_XPR4init(ReadCommand, WriteCommand)i2c.initialize()if(gpio_init_enable): InitGPIO()# ##### ##### Command call(s) start here ##### #####  print("Setting DLPC3436 Input Source to Raspberry Pi...")Summary = WriteDisplayImageCurtain(1,Color.Black)Summary = WriteSourceSelect(Source.ExternalParallelPort, Set.Disabled)#Summary = WriteInputImageSize(1920, 1080)print("Configuring DLPC3436 Source Settings for Raspberry Pi...")#Summary = WriteActuatorGlobalDacOutputEnable(Set.Enabled)#Summary = WriteExternalVideoSourceFormatSelect(ExternalVideoFormat.Rgb666)#Summary = WriteVideoChromaChannelSwapSelect(ChromaChannelSwap.Cbcr)#Summary = WriteParallelVideoControl(ClockSample.FallingEdge,  Polarity.ActiveHigh,  Polarity.ActiveLow,  Polarity.ActiveLow)#Summary = WriteColorCoordinateAdjustmentControl(0)#Summary, BitRate, PixelMapMode = ReadFpdLinkConfiguration()#Summary = WriteDelay(50)time.sleep(1)Summary = WriteDisplayImageCurtain(0,Color.Black)return "completed"# ##### ##### Command call(s) end here ##### #####i2c.terminate()

index.html如下。

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><a href="/start">开始</a><button onclick="start()">开始</button><h1 id="result"></h1><script>function start(){console.log("start")fetch("/start").then(response => response.text()).then(data => {console.log(data)document.getElementById("result").innerText=data;});}
</script><form onsubmit="return reload(this)" ><input type="submit" value="显示图片" /></form><img src="data:image.jpg"  id="showViewImg" /><script>function reload() {  const showImg = document.getElementById('showViewImg');const ts=(new Date()).getTime();showImg.src=`image.jpg?ts=${ts}`;return false;}</script><form onsubmit="return reload2(this)" ><input type="submit" value="显示图片2" /></form><img src="data:image2.jpg"  id="showViewImg2" /><script>function reload2() {  const showImg = document.getElementById('showViewImg2');const ts=(new Date()).getTime();showImg.src=`image2.jpg?ts=${ts}`;return false;}</script><script>setInterval(reload,1000);</script>  </body>
</html>

手机控制树莓派驱动投影仪DLPDLCR230NPEVM相关推荐

  1. 树莓派笔记15:手机控制树莓派小车

    1 成果展示 花了点时间做了简单的手机控制树莓派小车项目,其实主要是对之前各种学习内容的一个综合利用,也特地抽出时间学习了一下最基本的Android开发.下面的图片是成果的展示,树莓派小车由树莓派.小 ...

  2. 使用安卓手机控制树莓派

    在特殊情况下,没有用于树莓派显示的显示器,用电脑控制树莓派也不方便,这时可以通过手中的手机来登陆树莓派,这种方法仅仅需要一部手机,条件非常容易满足.这篇文章教大家如何用手机的手机连接树莓派,并将手机的 ...

  3. 手机控制树莓派linux,使用安卓手机控制树莓派

    在特殊情况下,没有用于树莓派显示的显示器,用电脑控制树莓派也不方便,这时可以通过手中的手机来登陆树莓派,这种方法仅仅需要一部手机,条件非常容易满足.这篇文章教大家如何用手机的手机连接树莓派,并将手机的 ...

  4. 使用Android手机控制树莓派操作流程

    使用Android手机控制树莓派操作流程 二次排版请看此连接:详细请看二次排版,有图有真相直达: 如果你觉得用计算机来控制树莓派不太方便,要求路由器网线等比较多,那么今天我就简单的说说如何用安卓手机来 ...

  5. Android手机控制树莓派制作的四驱小车

    -------更新 完整的代码放在Github上了: 服务端:https://github.com/darlinglele/raspberry-server 手机客户端: https://github ...

  6. 手机控制树莓派云台并传回图像

    本文是对https://blog.csdn.net/wangzhenyang2/article/details/81606700的实际演示 通过树莓派摄像头传回实时图像给手机APP 与推文不同推文不同 ...

  7. 手机控制树莓派linux,怎样用PC或手机远程控制树莓派

    您需要: 1. Raspberry Pi 3(带SD卡). 2. 2安培USB电源. 步骤1:在Pi中安装操作系统 您可以如果您已经在Pi中安装了操作系统,请跳过此步骤. 步骤2:下载VNC View ...

  8. python语音控制手机_python 树莓派语音控制普通台灯教程-Python 实用宝典

    阅读这篇文章前,这两篇文章可能对你会有所帮助: 利用智能音箱语音控制电脑开关机 (必读,否则你可能不知道我在说什么) 先看看效果: 完成这项有趣的实验,你所需要的材料有: 1.电烙铁 2.一个8050 ...

  9. matlab控制树莓派3b,树莓派3B+ 手机h5网页控制GPIO

    ezgif-4-5d181e9b42.gif 本文介绍如何在H5页面控制树莓派GPIO 仅实现以BCM编码方式控制GPIO,其他方式未做. 演示地址:http://gpio.exmll.cn/ 点击B ...

  10. WeMos下实现小车避障与手机控制

    参考:WeMos下实现小车避障与手机控制 作者:爱学习的小王呀 发布时间:2020-10-02 10:17:45 网址:https://blog.csdn.net/hongliwong/article ...

最新文章

  1. 你住的城市7.5亿年前长啥样?这张互动地图能让你看到
  2. linux 学习笔记 (五)
  3. 阶乘在c语言代码大全,求10000的阶乘(c语言代码实现)
  4. access开发精要(14)-货币与数字类型格式(2)
  5. java数组子类型_[改善Java代码]数组的真实类型必须是泛型类型的子类型
  6. java接口配置文件_Java读取property配置文件,另接口的配置
  7. java计算整数出现的次数_[剑指offer题解][Java]1到n整数中1出现的次数
  8. input的属性AutoComplete——关闭浏览器文本框自动提示
  9. 令新手头痛的java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet错误...
  10. C++_类和对象_C++多态_虚析构和纯虚析构函数---C++语言工作笔记074
  11. azure云数据库_Azure SQL数据库的安全注意事项
  12. 微软 Windows 再度“围剿” Google Chrome
  13. python中文叫什么-python中文叫什么
  14. P4049 [JSOI2007]合金
  15. 电脑主板线路连接图解_机箱线怎么接主板 DIY电脑机箱跳线与主板连接图解(2)...
  16. 恶意软件隐身术:把可执行文件隐藏在注册表里
  17. 为什么很多IT公司不喜欢进过培训机构的人呢?
  18. 递归查询数据库中树状数据
  19. Mixly制作的MP3播放和七彩灯、台灯控制例子
  20. java获取double类型区间随机数

热门文章

  1. 《SQL进阶教程》学习
  2. neo4j-入门---学习复杂关系使用CQL语句操作图数据库(二)
  3. 西安邮电大学计算机学校转专业,2021年西安邮电大学大一新生转专业及入学考试相关规定...
  4. Sat Sep 25 07:38:46 Local time zone must be set--see zic manual page 2021
  5. POJ 3088 Push Botton Lock 笔记
  6. pygame UI 框架
  7. 用户发送的eth值msg.value,在合约中以wei为单位。
  8. 3D动作绑定_3dmax【动画技巧】骨骼工具快速制作多动作人物动画
  9. 51GIF GIF动图中文搜索平台,表情包发源地,GIF动图素材库
  10. strconv,strings的学习(三)