html 显示温度,温度计.html · BillGreen/dragWEB - Gitee.com

Title

* {

margin: 0;

padding: 0;

}

.container {

display: flex;

height: 100vh;

overflow: hidden;

}

.left-nav {

width: 270px;

background-color: #fff;

}

.right-container {

flex: 1;

background-color: #fff

}

var $ = go.GraphObject.make;

var dragContent = $(go.Diagram, "dragContent", {

"toolManager.mouseWheelBehavior": go.ToolManager.WheelZoom,//缩放

"animationManager.duration": 800,

"undoManager.isEnabled": true, // enable Ctrl-Z to undo and Ctrl-Y to redo

allowDrop: true,

"grid.visible": true,//绘制网格

initialContentAlignment: go.Spot.Center,//图形在居中的位置开始绘制

})

var ORIGINAL_HEIGHT = 400;

dragContent.nodeTemplateMap.add("wenduji", $(go.Node, "Spot",

{

resizable: true,

resizeObjectName: "BarSpace",

locationObjectName: "Bulb",

locationSpot: go.Spot.Center

},

$(go.Shape,

{name: "BarSpace", width: 25, height: ORIGINAL_HEIGHT, strokeWidth: 0, fill: "rgba(0,0,0,.05)"},

new go.Binding("height").makeTwoWay()

),

// Farenheit scale, on the left:

$(go.Panel, "Graduated",

{

background: "white",

graduatedMin: -40, graduatedMax: 80,

graduatedTickBase: 0, graduatedTickUnit: 1,

alignment: go.Spot.BottomLeft,

alignmentFocus: go.Spot.BottomLeft,

alignmentFocusName: "line"

},

new go.Binding("graduatedMax", "", function (data) {

if (data.type === "scaling") return 80;

return (data.height * 0.3) - 40;

}),

$(go.Shape, {name: "line", geometryString: "M0 0 V-" + ORIGINAL_HEIGHT, stroke: "gray"},

new go.Binding("height")),

$(go.Shape, {alignmentFocus: go.Spot.Bottom, interval: 2, strokeWidth: 1, geometryString: "M0 0 V15"}),

$(go.Shape, {alignmentFocus: go.Spot.Bottom, interval: 10, strokeWidth: 2, geometryString: "M0 0 V20"}),

$(go.TextBlock, {interval: 20, font: "22px Georgia", alignmentFocus: new go.Spot(1, 0.5, 20, 0)}),

// Mark 32 degrees on the farenheit scale:

$(go.TextBlock, {

interval: 32, graduatedFunction: function (n) {

return n === 32 ? "32—" : ""

},

font: "bold 12px Georgia", stroke: "red", alignmentFocus: new go.Spot(1, 0.5, 20, 0)

})

),

// Mercury bar, which represents the values of farenheit and celsius

$(go.Shape,

{

width: 25, strokeWidth: 0, fill: "red",

alignment: go.Spot.Bottom,

alignmentFocus: go.Spot.Bottom,

},

new go.Binding('fill', 'type', function (t) {

return t === "scaling" ? "lightcoral" : "red"

}),

// To determine the mercury level, look at both data.farenheit and data.celsius, but prefer celsius

new go.Binding("height", "", function (data) {

var thermometerHeight = ORIGINAL_HEIGHT;

if (data.type === "scaling") thermometerHeight = data.height;

if (data.celsius !== undefined) {

// (celsius + minimum value) / (total celsius range) * height

return Math.max(0, ((data.celsius + 40) / 67) * thermometerHeight);

} else if (data.farenheit !== undefined) {

// (farenheit + minimum value) / (total farenheit range) * height

return Math.max(0, ((data.farenheit + 40) / 120) * thermometerHeight);

} else {

return 0;

}

}

),

new go.Binding("maxSize", "height", function (h) {

return new go.Size(NaN, h)

})

),

// Celsius scale, on the right:

$(go.Panel, "Graduated",

{

background: "white",

// -40 to 27 because we picked -40 to 80 for farenheit, and want them to line up

graduatedMin: -40, graduatedMax: 27,

graduatedTickBase: 0, graduatedTickUnit: 1,

alignment: go.Spot.BottomRight,

alignmentFocus: go.Spot.BottomRight,

alignmentFocusName: "line2"

},

new go.Binding("graduatedMax", "", function (data) {

if (data.type === "scaling") return 80;

return (data.height * 0.1675) - 40;

}),

$(go.Shape, {name: "line2", geometryString: "M0 0 V-" + ORIGINAL_HEIGHT, stroke: "gray"},

new go.Binding("height")),

$(go.Shape, {interval: 2, strokeWidth: 1, geometryString: "M0 0 V15"}),

$(go.Shape, {interval: 10, strokeWidth: 2, geometryString: "M0 0 V20"}),

$(go.TextBlock, {

interval: 20, textAlign: "left", font: "22px Georgia",

alignmentFocus: go.Spot.Left, segmentOffset: new go.Point(0, 22)

})

),

// Cosmetic: The stem and bulb

$(go.Shape,

{

width: 25, height: 10, strokeWidth: 0, fill: "red",

alignment: go.Spot.Bottom

},

new go.Binding('fill', 'type', function (t) {

return t === "scaling" ? "lightcoral" : "red"

})

),

$(go.Shape, "Circle",

{

name: "Bulb",

width: 55, height: 55, strokeWidth: 0, fill: "red",

alignment: go.Spot.Bottom,

alignmentFocus: go.Spot.Top,

},

new go.Binding('fill', 'type', function (t) {

return t === "scaling" ? "lightcoral" : "red"

})

)

) // end node template

)

var dragPalette = $(go.Palette, "dragNav", {

"animationManager.duration": 800,

initialContentAlignment: go.Spot.Center,

nodeTemplateMap: dragContent.nodeTemplateMap,

initialScale:0.1

})

var model = $(go.GraphLinksModel)

model.nodeDataArray = [

{category: "wenduji", name: "as", height: 800, celsius: 40},

]

dragPalette.model = model;

function save() {

var json = dragContent.model.toJson();

console.log(json)

// dragContent.isModified = false;

}

// dragPalette.addBehavior('')

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ESP-01/ESP8266-01DHT11温度湿度传感器需要通过串口烧录的方式进行烧录。下面是烧录步骤: 1. 准备工作: - 一台电脑,安装好了Arduino IDE和USB转TTL串口线 - 一个ESP-01/ESP8266-01DHT11温度湿度传感器 - 杜邦线若干 - 5V电源(如USB口电源) 2. 连接电路: 将ESP-01/ESP8266-01DHT11温度湿度传感器通过杜邦线连接到USB转TTL串口线上。连线方式如下: - VCC引脚连接USB转TTL串口线的5V电源 - GND引脚连接USB转TTL串口线的GND - TX引脚连接USB转TTL串口线的RX - RX引脚连接USB转TTL串口线的TX 3. 打开Arduino IDE,选择端口 - 打开Arduino IDE,选择工具 -> 端口,选择USB转TTL串口线连接的端口 4. 下载ESP8266 flash download tool - 下载地址:https://www.espressif.com/en/support/download/other-tools - 安装ESP8266 flash download tool 5. 烧录固件 - 打开ESP8266 flash download tool,选择固件文件路径,文件名为 ESP8266_NONOS_SDK-master\bin\at\bin\blank.bin - 设定串口,波特率为 115200 - 按下ESP-01/ESP8266-01DHT11温度湿度传感器上的GPIO0引脚,并按下复位按钮,进入下载模式 - 点击下载按钮,等待下载完成 6. 上传代码 - 将GPIO0引脚拔出,按下复位按钮,退出下载模式 - 在Arduino IDE中打开您的代码 - 选择工具 -> 开发板 -> Generic ESP8266 Module - 选择工具 -> 端口,选择USB转TTL串口线连接的端口 - 点击上传按钮,等待上传完成 希望这些步骤能够帮助您烧录ESP-01/ESP8266-01DHT11温度湿度传感器。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值