npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

7segment-driver

v1.2.2

Published

A driver library for 7-segment displays

Readme

七段数码管驱动库 (7segment-driver)

简介

7segment-driver 是一个轻量级的七段数码管显示驱动程序库,支持在网页和Node.js环境中快速生成数码管显示所需的顶点数据。支持数字和部分特殊字符的显示,可自定义显示样式和布局。

安装方法

通过npm安装 (推荐用于Node.js项目或使用构建工具的项目)

npm install 7segment-driver

浏览器直接引入 (适合快速原型开发)

<script src="https://..../dist/index.umd.js"></script>

使用指南

本库提供三种模块化方案的支持:

  1. CommonJS (CJS) 格式 (Node.js环境)
const { createHexagonVertices } = require('7segment-driver');
const vertices = createHexagonVertices('88:88');
  1. ES Module (ESM) 格式 (现代前端项目)
import { createHexagonVertices } from '7segment-driver';
const vertices = createHexagonVertices('12:34');
  1. UMD 格式 (浏览器全局变量)
<script src="path/to/index.umd.js"></script>
<script>
  const vertices = SevenSegmentDriver.createHexagonVertices('2024');
</script>

API 文档

createHexagonVertices(content, options)

功能:生成七段数码管显示的顶点数据

参数

  • content (String): 要显示的内容,支持字符:0-9, :, *
  • options (Object): 可选配置项
    • long (Number): 数码管长边长度,默认20
    • short (Number): 数码管短边长度,默认20
    • angle (Number): 短边与长边的夹角(度),默认30
    • gap (Number): 数码管间距,默认10
    • cw (Number): 显示区域总宽度,默认400
    • ch (Number): 显示区域总高度,默认300

返回值:包含所有数码管顶点数据的数组

示例

// 显示时间格式
const vertices = createHexagonVertices('12:34:56', {
  long: 25,
  short: 18,
  angle: 30,
  gap: 8,
  cw: 500,
  ch: 200
});

// 简单数字显示
const simpleDisplay = createHexagonVertices('2024');

注意事项

  1. 内容字符串中不支持显示的字符将被忽略
  2. 建议根据实际显示区域大小调整cwch参数
  3. 角度参数angle建议保持在20-45度之间以获得最佳显示效果

应用场景

  • 电子时钟显示
  • 数字计数器
  • 仪表盘数字显示
  • 任何需要七段数码管风格显示的项目