Ubuntu16.04 安装Processing

本文介绍如何在Linux环境下安装Processing IDE,并提供了一段示例代码,该代码可在Processing IDE中运行,用于将图像转换为适用于Adafruit Thermal库的C头文件格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载

https://processing.org/ 上下载最新的linux 64bit版本gzip文件, 当前是 http://download.processing.org/processing-3.3.7-linux64.tgz .

安装

解压后移动到 /opt/ 目录

添加快捷方式

在 /usr/share/applications下新建新文件 processing-pde.desktop, 内容如下

[Desktop Entry]
Version=3.3.7
Type=Application
Name=Processing IDE
Icon=/opt/processing-3.3.7/lib/icons/pde-64.png
Exec=/opt/processing-3.3.7/processing
Comment=Processing IDE
Categories=Development;IDE;
Terminal=false

附: 用于从图片中提取LCD单色数组的代码

// THIS IS NOT ARDUINO CODE!  Runs in Processing IDE (www.processing.org).
// Convert image to C header file suitable for the Adafruit_Thermal library.

void setup() {
  // Select and load image
  selectInput("Select image file to convert:", "processImage");
}

void processImage(File image) {
  String      filename, basename;
  PImage      img;
  PrintWriter output;
  int         pixelNum, byteNum, bytesOnLine = 99,
              x, y, b, rowBytes, totalBytes, lastBit, sum;
  println("Loading image...");
  filename = image.getPath();
  img      = loadImage(image.getPath());

  // Morph filename into output filename and base name for data
  x = filename.lastIndexOf('.');
  if(x > 0) filename = filename.substring(0, x);  // Strip current extension
  x = filename.lastIndexOf('/');
  if(x > 0) basename = filename.substring(x + 1); // Strip path
  else      basename = filename;
  filename += ".h"; // Append '.h' to output filename
  println("Writing output to " + filename);

  // Calculate output size
  rowBytes   = (img.width + 7) / 8;
  totalBytes = rowBytes * img.height;
  // Convert image to B&W, make pixels readable
  img.filter(THRESHOLD);
  img.loadPixels();

  // Open header file for output (NOTE: WILL CLOBBER EXISTING .H FILE, if any)
  output = createWriter(filename); 

  // Write image dimensions and beginning of array
  output.println("#ifndef _" + basename + "_h_");
  output.println("#define _" + basename + "_h_");
  output.println();
  output.println("#define " + basename + "_width  " + img.width);
  output.println("#define " + basename + "_height " + img.height);
  output.println();
  output.print("static const uint8_t PROGMEM " + basename + "_data[] = {");

  // Generate body of array
  for(pixelNum=byteNum=y=0; y<img.height; y++) { // Each row...
    for(x=0; x<rowBytes; x++) { // Each 8-pixel block within row...
      lastBit = (x < rowBytes - 1) ? 1 : (1 << (rowBytes * 8 - img.width));
      sum     = 0; // Clear accumulated 8 bits
      for(b=128; b>=lastBit; b >>= 1) { // Each pixel within block...
        if((img.pixels[pixelNum++] & 1) == 0) sum |= b; // If black pixel, set bit
      }
      if(++bytesOnLine >= 10) { // Wrap nicely
          output.print("\n ");
          bytesOnLine = 0;
      }
      output.format(" 0x%02X", sum); // Write accumulated bits
      if(++byteNum < totalBytes) output.print(',');
    }
  }

  // End array, close file, exit program
  output.println();
  output.println("};");
  output.println();
  output.println("#endif // _" + basename + "_h_");
  output.flush();
  output.close();
  println("Done!");
  exit();
}

.

### 在 Xilinx Zynq-7000 系列器件上移植和安装 Ubuntu 16.04 的方法 #### 准备工作 在开始移植之前,需准备必要的硬件和软件环境。Zynq-7000 是一款集成了 ARM Cortex-A9 处理器和可编程逻辑的 SoC 器件,支持运行嵌入式 Linux 操作系统。为了成功移植 Ubuntu 16.04,需要完成以下准备工作: - **开发板配置**:确保目标设备已正确设置并连接到主机计算机。这通常涉及通过 JTAG 或 UART 接口调试以及 SD 卡作为启动介质[^1]。 - **工具链安装**:下载并安装最新的 Vivado 工具版本(推荐使用与项目兼容的具体版次)。Vivado 提供 Block Design 功能来设计硬件平台,并生成用于引导操作系统的比特流文件。 #### 创建硬件设计 利用 Vivado 中的 BLOCK DESIGN 来构建适合运行 Linux 的硬件架构。具体步骤如下所示: ```tcl # 使用 Tcl 脚本创建基础处理器系统 (Processing System) create_bd_cell -type ip -vlnv xilinx.com:ip:processing_system7 processing_system7_0 apply_bd_automation -rule xilinx.com:bd_rule:processing_system7 \ -config {make_external_masters true make_external_slaves true} [get_bd_cells processing_system7_0] # 配置 DDR 控制器和其他外设接口参数以适配实际硬件资源需求 set_property CONFIG.PCW_USE_S_AXI_HP0 1 [get_bd_cells processing_system7_0] regenerate_layout; validate_design save_bd_design ``` 上述脚本定义了一个基本处理子系统实例及其自动化互联规则应用过程。 #### 构建根文件系统 对于 Ubuntu 16.04 移植而言,建议采用预编译好的镜像或者自行定制 RootFS。可以借助 Buildroot 或 Yocto Project 这样的开源框架简化流程。 ##### 下载官方提供的 BSP 包含驱动程序和支持库组件: 访问 Xilinx 官方网站获取对应于所选 FPGA 版本的目标平台支持包(PSP)[^1]。 ##### 编辑 kernel configuration 文件启用特定功能选项如 USB 支持等必要模块加载能力调整。 最后打包成 ext4 格式的分区映射至 microSD 卡内指定区域位置以便后续加载执行。 #### 启动测试验证 当所有前期作业完成后即可尝试开机检验效果是否正常运作无误。如果遇到任何异常状况则返回排查可能存在的错误源直至完全解决为止。 ```bash # 示例命令序列展示如何从串口终端登录进入图形界面模式下的 ubuntu 用户空间环境 $ sudo dd if=ubuntu.img of=/dev/sdX bs=4M && sync $ boot login as 'root' with no password initially set. apt-get update && apt-get dist-upgrade -y reboot now ``` 以上即为整个基于 zynq soc 平台之上部署 linux 发行版本的大致概览描述。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值